Bits concept , How to Crack

Problem link :

Everyone solving this problem with bits concept , I know lots of things about bits but didn’t applied it in any problem.
So How to apply it in this problem Can anybody explain??

Plz anyone help??


Most of the people have solved this question using Binary Indexed Tree. You can read more about it from here:

An alternate approach to solving this question would be the divide and conquer strategy ( like the merge sort ) which I had used.
You can check out my solution if you wish to from here Link


Great link, thanks, cleared my doubt. +1

thanks @nellex