代码
/*
* @lc app=leetcode.cn id=137 lang=cpp
*
* [137] 只出现一次的数字 II
*/
// @lc code=start
class Solution {
public:
int singleNumber(vector<int>& nums) {
int one = 0, two = 0;
for (auto x: nums) {
one = (one ^ x) & ~two;
two = (two ^ x) & ~one;
}
return one;
}
};
// @lc code=end