You are given an array votes of length n, where each element is a candidate identifier (string or integer).
Implement two voting systems:
Return the candidate with the highest number of votes.
Return the candidate who has strictly more than n/2 votes.
null
(or
None
).
votes: List[Candidate]
pluralityWinner(votes) -> Candidate
majorityWinner(votes) -> Candidate | null
1 <= n <= 10^6
votes = ["A", "B", "A", "C", "B", "A"]
"A"
(3 votes)
null
(3 is not > 6/2)
votes = [2, 2, 1, 2]
2
2
(3 > 4/2)