Few lines in cpp O(n)


#1

Solution::solve(vector &A, int B) {
int n = A.size();
int count = 0;
unordered_map<int,int> m;
m[0]=1;
int x=0;
for(int i=0;i<n;i++)
{
x ^= A[i];
m[x]++;
count += m[x^B];
}
return count;
}