My issue
Only one unknown test case is failing for this solution. Kindly help me to identify the case, and how should I handle it.
I have seen the solution where we are sorting the array and checking each element such that arr[i] != arr[i+]. But I want to implement this solution using XOR operator. React out to me.
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int n;
cin>>n;
vector<int> arr(n);
for(int i = 0 ; i < n ; ++i){
cin>>arr[i];
}
if(n % 2 == 1){
cout<<"NO"<<endl;
continue;
}
int xorr = 0;
for(int i = 0 ; i < n ; ++i){
xorr = xorr ^ arr[i];
}
if(xorr == 0){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
}
return 0;
}
Problem Link: PETSTORE Problem - CodeChef