给出一个一组数组,除了特殊的一个外,里面的数字都出现了三次,
不使用额外的空间
public class Solution {
public int singleNumber(int[] A) {
int one = 0, two = 0, three = 0;
for(int i = 0; i < A.length; ++i){
two |= one & A[i];
one ^= A[i];
three = ~(one & two);
one &= three;
two &= three;
}
return one;
}
}
转载之http://www.cnblogs.com/x1957/p/3373994.html