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
xor
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
xor
0
0
1
1
= 3
xor =
1
^
2
=
3
0
1
2
3
4
5
1
2
1
3
2
5
result[0]
0
0
0
0
= 0
result[1]
0
0
0
0
= 0
0
1
2
3
4
5
1
2
1
3
2
5
i
num
0
0
0
1
= 1
result[0]
0
0
0
1
= 1
result[1]
0
0
0
0
= 0
result[0] =
0
^
1
=
1
0
1
2
3
4
5
1
2
1
3
2
5
i
num
0
0
1
0
= 2
result[0]
0
0
0
1
= 1
result[1]
0
0
1
0
= 2
result[1] =
0
^
2
=
2
0
1
2
3
4
5
1
2
1
3
2
5
i
num
0
0
0
1
= 1
result[0]
0
0
0
0
= 0
result[1]
0
0
1
0
= 2
result[0] =
1
^
1
=
0
0
1
2
3
4
5
1
2
1
3
2
5
i
num
0
0
1
0
= 2
result[0]
0
0
0
0
= 0
result[1]
0
0
0
1
= 1
(
2
&
2
) =
2
: group
1
0
1
2
3
4
5
1
2
1
3
2
5
i
num
0
1
0
1
= 5
result[0]
0
0
0
0
= 0
result[1]
0
0
1
1
= 3
(
5
&
2
) =
0
: group
0
0
1
2
3
4
5
1
2
1
3
2
5
result[0]
0
1
0
1
= 5
result[1]
0
0
1
1
= 3
single numbers = 5 and 3
algo
master
.
io
Step:
Two numbers appear once, everything else twice. XOR everything, then split the numbers by a bit where the two answers differ
0 / 29
Input
Example 1
Example 2
Example 3
Custom
nums
=
[1, 2, 1, 3, 2, 5]
0 / 29
algo
master
.
io
Step:
Two numbers appear once, everything else twice. XOR everything, then split the numbers by a bit where the two answers differ