Given an array find the number which comes with maximum frequency. It must work in O(n) time complexity

#include
#include
using namespace std;
int main() {
int n;
cin>>n;
int arr[n]={0};
map<int, int> m;
for(int i=0;i<n;i++)
{ cin>>arr[i];
m.insert(make_pair(arr[i],1));
}
int max=0,c;
for(int i=0;i<n;i++)
{ if(m[arr[i]]>0)
m[arr[i]]++;
if(max<m[arr[i]])
{
max=m[arr[i]];
c=arr[i];
}
}
cout<<c<<endl;
return 0;

}

isn’t it in o(n) time? i’m applying just one loop

Now it’s working https://ide.codingblocks.com/s/290001

ios_base::sync_with_stdio(false); cin.tie(NULL);

what does these two lines do?

and the code is still giving TLE?(“crying” emojis)

These are for fast I/O

and the code is still giving TLE?

No I shared the optimised code, it’s not giving TLE

CODE IS NOT VISIBLE.