I don’t understand what’s the difference between
while(t–)
{
int temp;
int count=0;
int n;
int A[100010];
for(int c=0;c<100010;c++)
A[c]=0;
cin>>n;
for(int a=1;a<=n;a++)
{
cin>>temp;
A[temp]++;
}
for(int a=1;a<=n;a++)
{
if(A[a]!=0)
count++;
}
cout<<count<<"\n";
}
and
while(t–)
{
int temp;
int count=0;
int n;
int A[100010];
for(int c=0;c<100010;c++)
A[c]=0;
cin>>n;
for(int a=1;a<=n;a++)
{
cin>>temp;
if(A[temp]==0)
{
A[temp]++;
count++;
}
}
cout<<count<<"\n";
}
because the 1st one is giving a WA for the problem CAPPLE of DEC14, while the 2nd is 100% correct.
Can some one please clear this doubt??