A toll plaza records the lane id used by each passing vehicle. Determine which lane id was used most often. If two or more lane ids are tied for the highest count, report the smallest such id.
Line 1: an integer n, the number of vehicles.
Line 2: n space-separated integers, the lane id used by each vehicle.
A single integer: the most-used lane id, breaking ties toward the smallest id.
Example 1
Input
6 3 1 3 1 3 2
Expected
3
Explanation
Lane 3 is used 3 times, more than any other lane, so the answer is 3.
Example 2
Input
4 5 2 2 5
Expected
2
Explanation
Lanes 5 and 2 are each used twice. Breaking the tie toward the smaller id gives 2.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →