您的位置:首页 > 其它

leetcode:Single Number II

2014-06-15 00:39 344 查看
给出一个一组数组,除了特殊的一个外,里面的数字都出现了三次,

不使用额外的空间

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: