Winner of an election
Easy Accuracy: 46.84% Submissions: 1402 Points: 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

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.