2 out of 4 test cases are failing (TLE)
#include<iostream>
#include<unordered_map>
using namespace std;
int arr[10000000];
int main(){
int n;
cin>>n;
int cnt = 0;
int ans = -1;
unordered_map<int,int> h;
for(int i=0; i<n; i++){
h[i] = 0;
}
for(int i=0; i<n; i++){
cin>>arr[i];
h[arr[i]]++;
if(cnt < h[arr[i]]){
cnt = h[arr[i]];
ans = arr[i];
}
}
cout<<ans<<endl;
return 0;
}