 All Problems
Reverse Bits
easy
bit manipulation
divide and conquer
amazon
apple
microsoft

Reverse bits of a given 32-bit unsigned integer.

Example 1:

Input:  43261596
Output: 964176192

(Binary: 00000010100101000001111010011100 → 00111001011110000010100101000000)

Example 2:

Input:  4294967293
Output: 3221225471

(Binary: 11111111111111111111111111111101 → 10111111111111111111111111111111)

Constraints:

  • The input is a 32-bit unsigned integer.

Input format: A single non-negative integer.

Output format: The reversed bits as an unsigned 32-bit integer.

Run to check your code against the sample cases, or submit to run every case