Single NumberII
public int singleNumberII(int[] A) {
// write your code here
int[] bit = new int[32];
int ret = 0;
for(int i = 0; i < 32; i++){
for(int j = 0; j < A.length; j++){
bit[i] += A[j] >> i & 1; //用来把一个整数拆成Bit位
bit[i] %= 3;//三进制
}
ret |= bit[i] << i;
}
return ret;
}Last updated