# Help me in solving PETSTORE problem

### 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

@smeet8267
See the xor logic won’t work like for test case:-
1
6
1 2 3 4 8 12
U end up having xor 0 but its not possible to divide them into two same multiset.
so the answer would be NO but your code will print yes

1 Like

Thank you so much for pointing that out. I was really confused.