Only two testcase passed

#include<bits/stdc++.h>
using namespace std;

int ans(vectora){
int maximum = 0;
int res = -1;
if(a.size()==0){
return -1;
}
unordered_map<int,int>umap;
for(int i=0;i<a.size();i++){
umap[a[i]]++;
}

for(auto it=umap.begin();it!=umap.end();it++){
if(it->second>maximum){
maximum = it->second;
res = it->first;
}
}

return res;

}

int main() {
int n;
cin>>n;
vectora;
for(int i=0;i<n;i++){
int x;
cin>>x;
a.push_back(x);
}

cout << ans(a) << endl;

}

Please save you code on ide.codingblocks.com and then share its link.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.