BETA

Difficulty Level: Easy

Submissions: 17332 Accuracy:

37.42%

Majority Element

Write a program to find the majority element in the array. A majority element in an array A[] of size n is an element that appears more than n/2 times (and hence there is at most one such element).  If input array doesn't contain a majority element, then output "NO Majority Element"

Input:  The first line of the input contains T denoting the number of testcases. The first line of the test case will be the size of array and second line will be the elements of the array.
Output: For each test case the output will be the majority element of the array.
Constraints:

1 <=T<= 100

1 <=N<= 100

0 <= a[i]<= 100


Example:

Input:

2
5
3 1 3 3 2
3
1 2 3

Output:
3
NO Majority Element

** For More Input/Output Examples Use 'Expected Output' option **

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.