Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Counting Bits
Bookmark
Input
Example 1
Example 2
Example 3
Custom
n
=
5
0
1
2
3
4
5
0
0
0
0
0
0
algo
master
.
io
Step:
Count the 1-bits of every number from 0 to 5. Reuse earlier answers: ans[i] = ans[i & (i-1)] + 1
0 / 12
Input
Example 1
Example 2
Example 3
Custom
n
=
5
0 / 12
0
1
2
3
4
5
0
0
0
0
0
0
algo
master
.
io
Step:
Count the 1-bits of every number from 0 to 5. Reuse earlier answers: ans[i] = ans[i & (i-1)] + 1