Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Reverse Bits
Bookmark
Input
Example 1: 00101011
Example 2: 00001101
Example 3: 10110111
Custom
n
=
43
n
7
6
5
4
3
2
1
0
result
7
6
5
4
3
2
1
0
0
0
1
0
1
0
1
1
n
7
6
5
4
3
2
1
0
result
7
6
5
4
3
2
1
0
0
0
1
0
1
0
1
1
n
= 43
7
6
5
4
3
2
1
0
result
= 1
7
6
5
4
3
2
1
0
0
0
1
0
1
0
1
1
1
result = (result << 1) |
1
=
1
n
= 21
7
6
5
4
3
2
1
0
result
= 3
7
6
5
4
3
2
1
0
0
0
1
0
1
0
1
1
1
1
result = (result << 1) |
1
=
3
n
= 10
7
6
5
4
3
2
1
0
result
= 6
7
6
5
4
3
2
1
0
0
0
1
0
1
0
1
1
1
1
0
result = (result << 1) |
0
=
6
n
= 5
7
6
5
4
3
2
1
0
result
= 13
7
6
5
4
3
2
1
0
0
0
1
0
1
0
1
1
1
1
0
1
result = (result << 1) |
1
=
13
n
= 2
7
6
5
4
3
2
1
0
result
= 13
7
6
5
4
3
2
1
0
0
0
1
0
1
0
1
1
1
1
0
1
0
bit = n & 1 =
0
n
= 1
7
6
5
4
3
2
1
0
result
= 26
7
6
5
4
3
2
1
0
0
0
1
0
1
0
1
1
1
1
0
1
0
1
bit = n & 1 =
1
n
= 0
7
6
5
4
3
2
1
0
result
= 53
7
6
5
4
3
2
1
0
0
0
1
0
1
0
1
1
1
1
0
1
0
1
0
bit = n & 1 =
0
n
= 0
7
6
5
4
3
2
1
0
result
= 106
7
6
5
4
3
2
1
0
0
0
1
0
1
0
1
1
1
1
0
1
0
1
0
0
bit = n & 1 =
0
n
= 43
7
6
5
4
3
2
1
0
result
= 212
7
6
5
4
3
2
1
0
0
0
1
0
1
0
1
1
1
1
0
1
0
1
0
0
reversed: 43 becomes 212
algo
master
.
io
Step:
Reverse the 8 bits of n = 43 (00101011): pull bits off the right of n and push them onto the right of result
0 / 26
Input
Example 1: 00101011
Example 2: 00001101
Example 3: 10110111
Custom
n
=
43
0 / 26
algo
master
.
io
Step:
Reverse the 8 bits of n = 43 (00101011): pull bits off the right of n and push them onto the right of result