We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Please find the code below.
Test cases passed 1,2 and 16 are passing.
Rest all are failing.
`c
int main(){
int t;
scanf("%d",&t);
while(t--){
long long int result = 0;
long int n;
scanf("%ld",&n);
long long int temp[100000] = {0};
for(long int x=0;x
long long int te;
scanf("%lld",&te);
temp[te]++;
}
for(long long int j=0;j<100000;j++){
if(temp[j]>1)
result += temp[j]*(temp[j]-1);
}
printf("%lld\n",result);
}
return 0;
}
`
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Pairs
You are viewing a single comment's thread. Return to all comments →
Please find the code below. Test cases passed 1,2 and 16 are passing. Rest all are failing.
`c int main(){ int t; scanf("%d",&t); while(t--){ long long int result = 0; long int n; scanf("%ld",&n);
long long int temp[100000] = {0}; for(long int x=0;x long long int te; scanf("%lld",&te); temp[te]++; } for(long long int j=0;j<100000;j++){ if(temp[j]>1) result += temp[j]*(temp[j]-1);
return 0; } `