Dear codechef Team, i just wanted to ask that what is wrong with my solution as thought it matches the pseudo code of the editorial…
Also for the folloeing TEST CASE :
Input :
1
4
1 7 9 7
output:
3
As my solution gave the correct answer for this test case but my friend’s solution did not gave correct answer fro this but still it got AC and i got WA
Here is my solution:
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
int t,n,a[100005],x,l=0,max=0;
for(int i=0;i<100006;i++)
a[i]=0;
cin>>t;
while(t--)
{ l=0;
cin>>n;
for(int i=1;i<=n;i++)
{cin>>x;a[x]=x;}
for(int i=1;i<100006;i++)
{if(a[i]) l++; }
cout<<l<<"\n";
}
return 0;
}
And here is my friends solution:
#include<stdio.h>
int main()
{
int i,t,n,a,j,b[100001],size;
scanf("%d",&t);
while(t--)
{
size=0;
scanf("%d",&n);
for(i=0;i<n;i++)
b[i]=0;
for(i=0;i<n;i++)
{
scanf("%d",&a);
b[a-1]=-1;
}
for(i=0;i<n;i++)
{
if(b[i]==-1)
size++;
}
printf("%d\n",size);
}
return 0;
}
I don’t want to point on someones solution but want to know if i m going some where wrong !!!
Pls Help !!!