Find mode in a range in logarithmic time

Revision en1, by Hope_is_a_good_thing, 2021-02-02 18:00:52

Given a sorted array A of n elements. We are given n queries of the type [l, r] where l and r are the indices. 0 <= l , r < n In each query, we have to find out the mode in the range [l,r] both inclusive. We can use no more than n * log(n) memory and the solution should run in n * log(n) time.

Can we do it in given constraints on memory and time?

Tags mode

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Hope_is_a_good_thing 2021-02-02 18:00:52 397 Initial revision (published)