The idea is come from the manipulation solution of this question

https://discuss.leetcode.com/topic/17446/6-suggested-solutions-in-c-with-explanations/2

just use the mask to check the result's each bit is 1 or not

```
class Solution {
public:
int singleNumber(vector<int>& nums) {
int res = 0;
for(int i = 0, mask = 1; i < 32; ++i, mask <<= 1){
int count = 0;
for(int j = 0; j < nums.size(); ++j){
if(mask & nums[j]) count++;//use mask to count the # of 1 in each bit
}
if(count % 3 == 1) res |= mask;//to decide the bit of res is 1 or not
}
return res;
}
};
```

I think if you can understand my solution, you can also understand other solutions.