# MODEFREQ DOUBT

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;
}
}
}
}

Edit: Here it is

Try out this case:
1
5
1 1 1 1 1

SORRY WRONG WINDOW

Then how did it worked for n>100?

Because, there is a very high possibility that N > 100 does not have any cases where all the elements are the same.

Okok
Thanks man!!!

I am sorry. I do not know JAVA. All i can do is try to provide TCs but it works on any small input i give.

mine giving correct for that tc

Try this
1
3
1 2 1

giving 1 thats correct…
mine is WA in subtask >100

It usually is due to a fundamental flaw which might be captured by a small example in this case as there is no chance of overflow or related stuff