Reverse the bits of a 32-bit unsigned integer and return the resulting value.
Given a 32-bit unsigned integer, reverse its bits and return the integer you get after reversing.
Treat the input as a fixed-width 32-bit value. The leftmost bit becomes the rightmost bit, the second leftmost becomes the second rightmost, and so on.
For example, if the input bits are:
clike
00000010100101000001111010011100then the reversed bits are:
clike
00111001011110000010100101000000Return the decimal value of the reversed bit pattern.
n representing a 32-bit unsigned value.n.Example 1
Input
n = 43261596
Output
964176192
Explanation
The binary form of 43261596 is 00000010100101000001111010011100. Reversing the 32 bits gives 00111001011110000010100101000000, which is 964176192.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.