103. Class Monitor Election (Majority Vote)

Acceptance — 0 accepted 0 submissions

Easy
ArraysHashing
No companies listed
To become class monitor, a candidate needs more than half of all votes, a strict majority.

Given all the votes (candidate numbers), print the winner. If nobody has a strict majority, print No Majority.

Input Format
The first line has n, the number of votes.
The second line has n candidate numbers.

Output Format
Print the winning candidate's number, or No Majority.

Constraints
• 1 ≤ n ≤ 10^5
• 1 ≤ candidate ≤ 10^9

Example 1

Input
7
2 2 1 1 1 2 2
Output
2

Explanation Candidate 2 got 4 of 7 votes, more than half.

Example 2

Input
4
1 1 2 2
Output
No Majority

Explanation Each has exactly half, which is not a strict majority.

Example 3

Input
1
5
Output
5

Explanation The only vote decides it.

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
2
No results yet
Run your code to test it against the sample cases.
Problem List