You are given a binary array consists of 0's and 1's , and q queries . q can be large !
in each query you are given a certain range [L , R].
suppose a[] = {1,0,0,1}
L = 1 , R = 3 .
do toggling , resultant array = {0,1,1,1}
L = 1 , R =4
count all one's , ans = 3.
you have to either toggle bits in the given range i.e make 0 = 1 and 1 = 0 .
and on another query you are about to count all 1's in the range of [L,R]. **** The problem gives a feel of segment tree + lazy propogation . but how to do toggling in segment tree .
how should we update the lazy tree !
Any idea !