votes is the number of the candidate a ballot went to. One candidate is known to have received **strictly more than half** of all the votes.
Return that candidate's number.
Counting with a dictionary is the obvious route. Can you do it in linear time with O(1) extra memory?votes=[7, 4, 7, 7, 2] → 7
Candidate 7 got 3 of the 5 votes, which is more than half.
votes=[-5] → -5
A single ballot is a majority on its own.
votes=[1, 9, 9, 1, 9, 1, 9] → 9
9 has four of the seven votes, while 1 has only three.
votes=[7, 4, 7, 7, 2]
7
Run checks the first 3 tests in your browser. Submit checks all 41 tests on the server, hidden ones included.