Reverse Bits

Easy

Reverse the bits of a given 32-bit unsigned integer n and return the result.

Use the unsigned 32-bit value in your answer: reverseBits(1) is 2147483648, not -2147483648.

Example 1

reverseBits()
Input
n = 43261596
Output
964176192

Why

00000010100101000001111010011100 → 00111001011110000010100101000000
Constraints
0 <= n <= 2^32 - 1

Topics

Bit ManipulationDivide and Conquer

Implement reverseBits in the editor and return the answer — printing it is never graded.