Majority Element - I
easy
1. Give an array of size 'n'. 2. Find Majority element and print it(if exist), otherwise print "No Majority Element exist". 3. Majority element-> if frequency of an element is more than n/2, then that element is majority element. 3. Note : solve the problem in linear time and in O(1) space.
Constraints
1. 1 <= n <= 10^4 2. -10^9 < arr[n] < 10^9
Format
Input
Array = [2,2,1,1,1,2,2] Array = [1, 1, 5, 5, 3, 6]
Output
2 No Majority Element exist
Example
Sample Input
7
2 2 1 1 1 2 2
Sample Output
2
Question Video