Description
Reverse bits of a given 32 bits unsigned integer. Return the integer that results from reversing the binary representation of the input. For example, reversing 00000010100101000001111010011100 gives 00111001011110000010100101000000.
Examples
Input:
n = 43261596Output:
964176192Explanation:
Binary reversal of the input.
Input:
n = 1Output:
2147483648Explanation:
The binary of 1 is 00000000000000000000000000000001. When reversed, it becomes 10000000000000000000000000000000, which equals 2147483648 in decimal. This demonstrates how a single bit at the least significant position moves to the most significant position.
Input:
n = 0Output:
0Explanation:
The binary of 0 is 00000000000000000000000000000000 (all zeros). When reversed, it remains 00000000000000000000000000000000, so the output is still 0. This is a special edge case where the input and output are identical.
Constraints
- •
Input is a 32-bit unsigned integer.