Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

Reverse Bits

Easy

Topics
Bit Manipulation

Reverse the bits of a given 32-bit unsigned integer. Return the resulting unsigned integer represented as a (possibly large) number.

For example, the input 43261596 in binary is 00000010100101000001111010011100. Reversing gives 00111001011110000010100101000000 which is 964176192.

Example 1

Input:  n = 43261596
Output: 964176192

Example 2

Input:  n = 4294967293
Output: 3221225471

Example 3

Input:  n = 0
Output: 0

Constraints

  • 0 <= n <= 2^32 - 1
Run ⌘' · Submit ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access