Hamlet_Jr's blog

By Hamlet_Jr, history, 6 years ago, In English

Say for , there is an array with 10^5 size. & there are 10^5 query.

In each query, there is given a range L-R .

within this range(inclusive) i want to find out how many distinct element remaining there??

Note: array elements are unsorted and any digit may occur frequently.

ex: 3 4 1 1 3 7 10

here if L=3,R=6 then the answer will be 3 because(distinct element within index 3 to 6 is 1,3,7)

i could do this using set if there only one query . but how can i do this if there 10^5 query within time limit 1s,2s or 3s .

thanks for advance

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it