Блог пользователя Bnahmad15

Автор Bnahmad15, история, 6 лет назад, По-английски

given an array of integers with (N <= 1e6) and Q (Q <= 1e6) queries with L and R.. what is the mostly repeated number in range [L,R] ? is there any fast way to work it out ?

  • Проголосовать: нравится
  • -4
  • Проголосовать: не нравится

»
6 лет назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

That is the range mode query problem. It has a lot of solution in with either just Sqrt-decomposition or MO's algorithm. You can also do it with bitset.

If you know that the number of times the mode appears in the range is large, you can refer to this problem.