https://leetcode.com/problems/single-number-ii/
Bitwise operators1
2
3
4
5
6
7
8
9
10class Solution {
public int singleNumber(int[] nums) {
int once = 0, twice = 0;
for (int num : nums) {
once = (~twice) & (once ^ num);
twice = (~once) & (twice ^ num);
}
return once;
}
}