I think this problem is a little unclear. In my point of view, the single one can be:

(1) the one which has different numbers than others. Can have 1 or 2 but not 3 numbers.

(2) the one which appears only once.

Which one is correct?

So we should consider about it when we are in the interview. The following code can solve the (1) case by adding one more line checking, instead of return result directly.

```
public int singleNumber(int[] nums) {
int res=0;
for(int i=0;i<32;i++){
int count = 0;
for(int j=0;j<nums.length;j++){
count+=(nums[j]>>i)&1;
}
res|=(count%3)<<i;
}
/*
*here solve 1,1,1,2,2 and 1,1,1,2 cases
*/
if(nums.length%3==2) return res/2;
else return res;
}
```

P.S.: if (1) is correct, in fact, it can also has 4,5..., but not 3 numbers. So this is not a porper assumption, because we cannot handle all these cases.