Dashboard
#73. Reverse BitsEasyBit Manipulation

Given a 32-bit unsigned integer n, reverse the bits of the binary representation of n and return the result.

Example 1:

Input: n = 00000000000000000000000000010101

Output:    2818572288 (10101000000000000000000000000000)

Explanation: Reversing 00000000000000000000000000010101, which represents the unsigned integer 21, gives us 10101000000000000000000000000000 which represents the unsigned integer 2818572288.

Examples
Example 1:
Input: n = 00000000000000000000000000010101
Output: 2818572288 (10101000000000000000000000000000)
Constraints
  • 1 <= input.length <= 10^5
Prerequisites
Target: O(N) time • O(1) spaceDivide and Conquer / Bit Manipulation
Socratic AI Tutor
Gemini 3.8 Flash
Loading editor...

Click "Run" or press Ctrl+Enter to execute test cases.