题目:
题解:
class Solution {public int[] singleNumber(int[] nums) {int xorsum = 0;for (int num : nums) {xorsum ^= num;}// 防止溢出int lsb = (xorsum == Integer.MIN_VALUE ? xorsum : xorsum & (-xorsum));int type1 = 0, type2 = 0;for (int num : nums) {if ((num & lsb) != 0) {type1 ^= num;} else {type2 ^= num;}}return new int[]{type1, type2};}
}