problem code : CNDY
I written a code and output matches with a given output but don’t understand how it shows wrong answer after submitting code.
below is my code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
int n;
int max=0;
int cnt=1;
cin>>n;
int a[2*n];
for(int i=0;i<2*n;i++){
cin>>a[i];
}
sort(a,a+(2*n));
for(int i=0;i<2*n-1;i++){
if(a[i]==a[i+1]){
cnt++;
if(cnt>max){
max=cnt;
}
}
}
if(max<=2)
cout<<"yes"<<endl;
else cout<<"no"<<endl;
}
return 0;
}