Simple C++ answer


#1

int Solution::solve(vector &A) {

int n=A.size();
int  ans=0;

for(int i=0;i<n;i++)
{
    if(i==0 || i==n-1)
    {
        if(n%2)
            ans=ans^A[i];
    }
    else
    {
        int x=i+1;
        int y=n-i;
        
        if(x%2 && y%2)
            ans=ans^A[i];
    }
}
return ans;

}