Competitive Programming

Hackerearth : Help Ashu

Problem Statement: https://www.hackerearth.com/practice/data-structures/advanced-data-structures/fenwick-binary-indexed-trees/practice-problems/algorithm/help-ashu-1/ Approach : We can solve the problem using Binary Index Tree(BIT). We store all the indexes which are odd. Now, in-case we have to find all the odd numbers we can simply find the sum in the range. To find the even numbers we simply have to subtract all the odd numbers… Continue reading Hackerearth : Help Ashu

Competitive Programming

Codeforces 665 C. Simple Strings

Problem Statement: http://codeforces.com/problemset/problem/665/C Approach : Simply dissociate the whole string into sequences that have similar consecutive characters. • If there are odd numbers of consecutive characters simply replace alternative characters. For example, “aaaaa” becomes “ababa”. • If there are even numbers of character do the same as above. However check that the last character of… Continue reading Codeforces 665 C. Simple Strings

Competitive Programming

Codeforces 673 A. Timofey and a tree

Problem Statement: http://codeforces.com/problemset/problem/763/A Approach : The easiest way to solve this problem is like this. First find all the edges which have nodes having dissimilar values. Let’s call these edges “Magic Edges”. These edges are basically those edges which shall connect two different sub-trees. Now, simply check whether all the “Magic Edges” have some common… Continue reading Codeforces 673 A. Timofey and a tree