Given an array A of N integers answer Q queries of type (L, R). Answer to a query (L, R) is the sum of distinct integers in the range A[L...R]
Constraints: N, Q <= 100000
0 <= L <= R < N
abs(A[i]) <= 1 000 000 000
I read somewhere that this can be done using persistence segment tree.
So, it would be helpful if one can explain that approach.
Other approach are welcome too.