1
class Solution {
2
public int[] singleNumber(int[] nums) {
3
if (nums == null || nums.length < 2 || nums.length % 2 != 0) {
4
throw new IllegalArgumentException("Invalid Input");
5
}
6

7
int aXORb = 0;
8
for (int n : nums) {
9
aXORb ^= n;
10
}
11

12
int rightSetBit = aXORb & -aXORb;
13
int a = 0;
14
for (int n : nums) {
15
if ((n & rightSetBit) != 0) {
16
a ^= n;
17
}
18
}
19

20
return new int[] {a, aXORb ^ a};
21
}
22
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0