giaminh8368's blog

By giaminh8368, history, 17 months 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

»
17 months 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).

»
17 months 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)