question goes like this.... given an array of n nos.and queries q the queries follow like this given range l to r (l<=r) for every query we have to find sum of elements which have an odd frequency in the given range
note : 1 based indexing is followed.............................................................................................
example : 5......n
1 2 2 2 1....elements
3..queries...
1 3...
1 4......
1 5......
output: 1..... 7..... 6.....
explanation : 1. in range 1 to 3 only 1 has odd frequecy i.e 1 so ans =1 !!! 2.in range 1 to 4 1 has frequency 1 and 2 has frequecy 3 so ans = 1*1 + 2*3 = 6 !!!
I am not able to solve this......question if time limit is 1 second.
We sum all entries of element in range?
Using the standard Mo's algorithm with two pointers should work within 1 second time limit for N ≤ 105. To keep the frequencies and the answer, do the following...
i know this but i am not able to code this....
This is how I usually code Mo's...