Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Single Number II
Bookmark
Input
Example 1
Example 2
Example 3
Custom
nums
=
[2, 2, 3, 2]
0
1
2
3
2
2
3
2
0
1
2
3
2
2
3
2
0
1
2
3
2
2
3
2
i
num
0
0
1
0
= 2
ones
0
0
0
0
= 0
twos
0
0
0
0
= 0
0
1
2
3
2
2
3
2
i
num
0
0
1
0
= 2
ones
0
0
1
0
= 2
twos
0
0
0
0
= 0
ones = (
0
^
2
) & ~
0
=
2
0
1
2
3
2
2
3
2
i
num
0
0
1
0
= 2
ones
0
0
1
0
= 2
twos
0
0
0
0
= 0
0
1
2
3
2
2
3
2
i
num
0
0
1
0
= 2
ones
0
0
0
0
= 0
twos
0
0
0
0
= 0
ones = (
2
^
2
) & ~
0
=
0
0
1
2
3
2
2
3
2
i
num
0
0
1
1
= 3
ones
0
0
0
0
= 0
twos
0
0
1
0
= 2
0
1
2
3
2
2
3
2
i
num
0
0
1
1
= 3
ones
0
0
0
1
= 1
twos
0
0
1
0
= 2
ones = (
0
^
3
) & ~
2
=
1
0
1
2
3
2
2
3
2
i
num
0
0
1
0
= 2
ones
0
0
0
1
= 1
twos
0
0
0
0
= 0
0
1
2
3
2
2
3
2
i
num
0
0
1
0
= 2
ones
0
0
1
1
= 3
twos
0
0
0
0
= 0
ones = (
1
^
2
) & ~
0
=
3
0
1
2
3
2
2
3
2
ones
0
0
1
1
= 3
twos
0
0
0
0
= 0
single number = 3
algo
master
.
io
Step:
Every number appears three times except one. Track bits seen once in ones and twice in twos: a third sighting erases the bit from both
0 / 14
Input
Example 1
Example 2
Example 3
Custom
nums
=
[2, 2, 3, 2]
0 / 14
algo
master
.
io
Step:
Every number appears three times except one. Track bits seen once in ones and twice in twos: a third sighting erases the bit from both