← All problems

Reverse Bits

medium

Given a 32-bit unsigned integer n, return the integer obtained by reversing the bits of its binary representation.

Peel one bit off the low end of n and place it at the low end of a growing result, shifting the result left each time — after 32 rounds, the result holds n's bits in reverse order.

Example

Input: n = 43261596        // 00000010100101000001111010011100
Output: 964176192          // 00111001011110000010100101000000
Loading...