Very simple and easy to understand


#1

Just dry run for odd sized and even sized array you will understand the flow
int Solution::solve(vector &A) {
int n=A.size();
int xr=0;
if(n%2==0) return 0;
for(int i=0;i<n;i+=2)
{
xr=xr^A[i];
}
return xr;
}