284. How Often Does the Commonest Appear
Foundation1000 ms256 MBSolved by 0%
Print how many times the most frequent value appears among n integers.
You are asked for the COUNT, not the value, so ties do not matter and there is no ordering question to resolve.
A map from value to count does it in one pass. Counting each value by rescanning the array is quadratic and the largest test rules it out.
Constraints - `1 ≤ n ≤ 200000` - `-1000000000 ≤ a[i] ≤ 1000000000`
Input
The first line contains an integer n.
The second line contains n integers.
Output
Print one integer, the highest frequency of any value.
Input4
1 2 2 3
Output2
Notehas one value appearing twice
Input1
1
Output1
Noteis a single element
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.