I am getting 70/100 in the below question.

the link of the question is:

https://www.codechef.com/LTIME87B/problems/MODEFREQ

And the solution is:

#include

#include

using namespace std;

int main()

{

int t;

cin>>t;

while(t–)

{

int n,i;

cin>>n;

int a[n],cnt[n]={0},d[n]={0};

for(i=0;i<n;i++)

cin>>a[i];

sort(a,a+n);

for(i=0;i<n;i++)

{

if(a[i]!=a[i+1])

{

d[count(a,a+n,a[i])]++;

}

}

int f=*max_element(d,d+n);

for(i=0;i<n;i++)

{

if(f==d[i])

{

cout<<i<<endl;

break;

}

}

}

}