easyBit ManipulationAppleAmazon
Mirror-Bit Flipper
A network stack reverses the bits of a 32-bit value to normalize MSB/LSB ordering.
Reverse the bits of a given 32-bit unsigned integer.
Choose approach
43261596
0Mapstate
r→3
bin→00000000000000000000000000000011
1/9
Narrationstep 1 of 9
After 4 bits: r=00000000000000000000000000000011.
Variables
i=4
r=3
bin=00000000000000000000000000000011
How to think about it
- 32 iterations regardless of n.
- Lookup tables cut this to 4 lookups.
Edge cases to catch in interview
- 0 -> 0.
- All ones -> all ones.
Examples
Example 1
0{"n":0,"values":[0]}
Try your own input
SpacePlay / pause
← / →Previous / next step
RReset to start
. or >Cycle speed