Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Single Number III
Bookmark
Input
Example 1
Example 2
Example 3
Custom
nums
=
[1, 2, 1, 3, 2, 5]
0
1
2
3
4
5
1
2
1
3
2
5
0
1
2
3
4
5
1
2
1
3
2
5
0
1
2
3
4
5
1
2
1
3
2
5
i
num
0
0
1
0
= 2
xorAll
0
0
1
1
= 3
xor =
1
^
2
=
3
0
1
2
3
4
5
1
2
1
3
2
5
i
num
0
0
1
0
= 2
xorAll
0
0
1
1
= 3
xor =
1
^
2
=
3
0
1
2
3
4
5
1
2
1
3
2
5
xorAll
0
1
1
0
= 6
diffBit
0
0
1
0
= 2
diff = xor & -xor =
6
&
-6
=
2
0
1
2
3
4
5
1
2
1
3
2
5
i
num
0
0
0
1
= 1
x
0
0
0
0
= 0
(
1
&
2
) =
0
:
skip
0
1
2
3
4
5
1
2
1
3
2
5
i
num
0
0
1
0
= 2
x
0
0
1
0
= 2
x =
0
^
2
=
2
0
1
2
3
4
5
1
2
1
3
2
5
i
num
0
0
1
1
= 3
x
0
0
1
0
= 2
(
3
&
2
) =
2
:
fold into x
0
1
2
3
4
5
1
2
1
3
2
5
i
num
0
0
1
0
= 2
x
0
0
0
1
= 1
(
2
&
2
) =
2
:
fold into x
0
1
2
3
4
5
1
2
1
3
2
5
i
num
0
1
0
1
= 5
x
0
0
1
1
= 3
(
5
&
2
) =
0
:
skip
0
1
2
3
4
5
1
2
1
3
2
5
x
0
0
1
1
= 3
xorAll ^ x
0
1
0
1
= 5
single numbers = 3 and 5
algo
master
.
io
Step:
Two numbers appear once, everything else twice. XOR everything, then use a bit where the two answers differ to isolate one of them
0 / 27
Input
Example 1
Example 2
Example 3
Custom
nums
=
[1, 2, 1, 3, 2, 5]
0 / 27
algo
master
.
io
Step:
Two numbers appear once, everything else twice. XOR everything, then use a bit where the two answers differ to isolate one of them