Loading...
Loading...
Loading...
A legacy device sends a 32-bit number with its bits in the opposite order. Read an unsigned 32-bit number and print the number you get by reversing its 32 bits, so the lowest bit becomes the highest.
Example 1
Input
1
Output
2147483648
The single 1 bit moves from the lowest place to the highest, giving 2^31.
Example 2
Input
43261596
Output
964176192
Try the problem first. Open one hint at a time.
Build the result one bit at a time: shift the result left, then add the lowest bit of n, then shift n right.
Repeat exactly 32 times, even when n becomes 0.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor