giaminh8368's blog

By giaminh8368, history, 2 years ago, In English

Hello. I recently met this problem but can't solve it, please help me solve it.

Given an array of n integers.

There are q queries. Each query gives us a subarray from l to r.

Find the maximum occurrence of a number in the subarray.

(Sorry for my bad English :) )

  • Vote: I like it
  • +4
  • Vote: I do not like it

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by giaminh8368 (previous revision, new revision, compare).

»
2 years ago, # |
  Vote: I like it +1 Vote: I do not like it

You can use Mo's algorithm to solve this problem in O(n sqrt n)