Most Frequent in a Slice
Answer Q queries (l, r): the highest frequency of any single value in al..r (the count of the mode).
Input: the first line has N and Q; the second line has the array; the next Q lines have l and r.
Output: one line per query with the mode's frequency.
Constraints:
- 1 ≤ N, Q ≤ 105 (tests use N, Q ≤ 1500)
- 1 ≤ ai ≤ 109
Sample Tests
Input 1
5 2 1 2 2 3 2 1 3 2 5
Output 1
2 3
Input 2
1 1 7 1 1
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.