Winner of an election
Submissions: 689   Accuracy:

44.65%

  Difficulty: Easy   Marks: 2

Given an array of names of candidates in an election. A candidate name in array represents a vote casted to the candidate. The task is to print the name of candidates received maximum vote. If there is tie, print lexicographically smaller name.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains an Integer N denoting number of votes and the second line contains N space separated strings.

Output:
For each test case, print the winner of election in new line.

Constraints:
1<=T<=100
2<=N<=105

1<=|String length|<=20

Example:
Input:
2
6
aaa bbb ccc bbb aaa  aaa
7
geeks for geeks for geeks aaa aaa

Output:
aaa
geeks

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

Author: arun03


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



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


to report an issue on this page.