/*
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.
Constraints:
1<=T<=100
2<=N<=105
1<=|String length|<=20
*/
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int n;
cin>>n;
map<string,int> m;
for(int i=0;i<n;i++){
string input;
cin>>input;
m[input]++;
}
int max=-1;
string s="";
for(auto i:m){
if(i.second>max){
max=i.second;
s=i.first;
}
}
cout<<s<<"\n";
}
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: