int Solution::singleNumber(const vector &A) {
int ones=0,twos=0;
for(int x: A){
ones=(x^ones)&(~twos); //tracks elements that appear one time
twos=(x^twos)&(~ones); // tracks element that appear two times
}
return ones;
}
int Solution::singleNumber(const vector &A) {
int ones=0,twos=0;
for(int x: A){
ones=(x^ones)&(~twos); //tracks elements that appear one time
twos=(x^twos)&(~ones); // tracks element that appear two times
}
return ones;
}