Reverse Integer Bits

Bit Manipulation Binary Algorithm

Reverse Integer Bits

Given an unsigned 32-bit integer, reverse its binary representation and return the resulting integer.

Requirements:

  • Do not use built-in functions that convert the number to a string to solve the problem.
  • Use bit manipulation operations such as bit shifting and bit masking.

Example:

Input:  n = 43261596
// Binary representation: 00000010100101000001111010011100

Output: 964176192
// Reversed binary: 00111001011110000010100101000000

Hint:
Iterate over each bit in the integer, and for each bit, shift it to its correct reversed position in the result integer.