Back to DSA

Reverse Bits

easy
Acceptance: 55%
Bit Manipulation

Given a 32-bit unsigned integer, reverse the order of its bits and return the resulting integer.

Examples

Example 1:
Input:n = 13 (00000000000000000000000000001101)
Output:2952790016 (10110000000000000000000000000000)
Example 2:
Input:n = 1 (00000000000000000000000000000001)
Output:2147483648 (10000000000000000000000000000000)

Hints

00:00
1234567