Treat n as exactly 32 bits, with leading zeros where needed. Reverse the order of those bits, so the lowest bit becomes the highest and the highest becomes the lowest. Return the new value as an unsigned integer. It can be larger than 2^31 - 1.
Example 1
Input
n = 6
Output
1610612736
Explanation
in 32 bits, n is 00000000000000000000000000000110. Read backwards that is 01100000000000000000000000000000, which is 1610612736.
Example 2
Input
n = 1
Output
2147483648
Explanation
n has a single 1 bit, in the lowest place. After the reversal it is the highest bit: 10000000000000000000000000000000. The value is above 2^31 - 1, so it must be returned as an unsigned number, not a negative one.
Constraints:
0 <= n <= 2^32 - 1
Tab indents. Press Esc, then Tab to leave the editor.
Ctrl or ⌘ + Enter runs the tests.
Run your code to see every test here. Nothing is submitted or recorded.