My issue
include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t,n,i,x,count=0;
cin>>t;
while(t--){
cin>>n;
int a[2*n];
for(i=0;i<2*n;i++){
cin>>a[i];
}
for(x=0;x<2*n;x++){
for(i=1;i<2*x;i++){
if(a[x]==a[i]){
count++;
}
i=i+1;
}
}
if(count>=2){
cout<<"NO"<<endl;
}
else{
cout<<"YES"<<endl;
}
}
}
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t,n,i,x,count=0;
cin>>t;
while(t--){
cin>>n;
int a[2*n];
for(i=0;i<2*n;i++){
cin>>a[i];
}
for(x=0;x<2*n;x++){
for(i=1;i<2*x;i++){
if(a[x]==a[i]){
count++;
}
i=i+1;
}
}
if(count>=2){
cout<<"NO"<<endl;
}
else{
cout<<"YES"<<endl;
}
}
}
Problem Link: Candies Practice Coding Problem