CodeOath
← All problems

Reverse Bits

Easy
bit-manipulation

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

Example:

Input: n = 43261596 (00000010100101000001111010011100)
Output: 964176192 (00111001011110000010100101000000)

Constraints:

  • n fits in 32 unsigned bits (0 <= n <= 2^32 - 1)