4 lines C++ solution using bits


#1
int Solution::singleNumber(const vector<int> &A) {
    int product;
    for(auto i : A){
        product = product^i;
    }
    return product;
}

#2

Damn! I could have never come up with such a solution.