Problem Statement
Find the majority element in an array. A majority element is an element that appears more than n/2 times. If no majority element exists, print "NONE".
Example
Input:
7 2 2 1 1 1 2 2
Output:
2
(2 appears 4 times, 4 > 3.5)
DEMO-C-32 โข Programming in C
Find the majority element in an array. A majority element is an element that appears more than n/2 times. If no majority element exists, print "NONE".
Input:
7 2 2 1 1 1 2 2
Output:
2
(2 appears 4 times, 4 > 3.5)
n, array
Element or NONE
Submit runs every public testcase in this browser. Results and code never leave this device.
7 2 2 1 1 1 2 2
2
4 1 2 3 4
NONE
3 1 1 2
1
5 3 3 3 2 1
3
9 7 7 7 7 7 7 7 7 7
7
11 5 5 5 5 5 6 6 6 6 6 6
6
C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.
/workspace/question