链接:https://leetcode-cn.com/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-ii-lcof/
代码
class Solution {
public:
int singleNumber(vector<int>& nums) {
int ones = 0, twos = 0;
for (auto x: nums) {
ones = (ones ^ x) & ~twos;
twos = (twos ^ x) & ~ones;
}
return ones;
}
};