Simple and Sweet, based on given hint


#1
int Solution::singleNumber(const vector<int> &A) {
int x=0;
for(int i=0;i<32;++i){
    int cnt0=0;
    int cnt1=0;
    for(auto num:A){
        if(num & 1<<i){
            cnt1++;
        }
        else{
            cnt0++;
        }
    }
    if(cnt1%3==1){
        x|=1<<i;
    }
    if(cnt0%3==1){
        x&=~(1<<i);
    }
}
return x;

}