distinct element

Revision en1, by Hamlet_Jr, 2018-07-06 08:56:51

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

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Hamlet_Jr 2018-07-06 08:56:51 577 Initial revision (published)