Majority Element
A value is a majority element if it appears more than N/2 times. Print it, or NONE if there is none.
Input: the first line has an integer N; the second line has N integers separated by spaces.
Output: the majority element or NONE.
Constraints:
- 1 ≤ N ≤ 2000
- −109 ≤ ai ≤ 109
Sample Tests
Input 1
5 3 3 4 3 2
Output 1
3
Input 2
4 1 1 2 2
Output 2
NONE
Discussion (opens after you solve — no spoilers before)
No comments yet.