Solutions using XOR logic with linear time complexity and constant(1) space complexity

Simple solution by XOR logic 

A number with XOR itself gives zero
A number with XOR zero gives itself

int Solution::singleNumber(const vector<int> &A) {
    int xorr = 0;
    int n = A.size();
    for(int i=0; i<n; i++){
        xorr ^= A[i];
    }
    return xorr;
}
Click here to start solving coding interview questions