Suppose I have created a Binary Indexed Tree with prefix sum of length N. The main array contains only 0
s and 1
s. Now I want to find which index has a prefix sum M(That means have exactly M 1
s).
Like my array is a[]={1,0,0,1,1};
prefix-sum would look like {1,1,1,2,3};
now 3rd index(0 based) has prefix sum of 2.
How can i find this index with BIT?
Thanks in advance.