I am getting 70/100 in the below question.
the link of the question is:
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;
}
}
}
}
Can you link your submission?
Edit: Here it is
Try out this case:
1
5
1 1 1 1 1
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.
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
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