class Solution {
public:
int singleNumber(vector<int>& nums) {
int sz = nums.size();
int result = 0;
for(int i = 0; i < 32; ++i){
int temp = 1 << i, times = 0;
for(int j = 0; j < sz; ++j){
if(nums[j] & temp)
++times;
}
result |= times%3 ? temp : 0;
}
return result;
}
};
137. Single Number II
最新推荐文章于 2022-01-26 11:09:47 发布