CitadelOA #13
Find Consistent Logs
Estimated MediumJudge-ready
Topics (AI-labelled)Two PointersHashing
Among the users appearing in the whole array, let f be the minimum number of occurrences. Find the maximum length of a contiguous subarray in which the highest user occurrence count is exactly f; it does not require every user in the subarray to have the same frequency.
Input
The first line contains n, followed by the user IDs; complete original bounds 1≤n≤300000, 1≤ID≤1000000000.
Output
Output a single integer, the answer.
Example 1
Input:
10
1 2 1 3 4 2 4 3 3 4
Output:
8
Example 2
Input:
3
1 1 1
Output:
3
Example 3
Input:
4
1 2 1 3
Output:
3
Example notes
The outputs of the three public examples are, in order: 8; 3; 3. These answers were verified by independent enumeration or direct simulation.
Editorial
Loading solution…