神一样的代码:

  • Post author:
  • Post category:其他


public static int singleNumber(int[] nums) {
int once = 0;
int twice = 0;
for (int i = 0; i < nums.length; i++) {
twice |= once & nums[i];
once ^= nums[i];
int not_three = ~(once & twice);
once = not_three & once;
twice = not_three & twice;
}
return once;
}

转载于:https://www.cnblogs.com/qinyongzhu/p/4977258.html