Question

Reverse bits of a given 32 bits unsigned integer.

This is abit_manip question.

Idea

  • Get the binary representation of a given decimal number (32 bit representation so append extra 0’s to the front if we need to)
  • Reverse the binary string
  • Convert the binary string to decimal
  • Return
  • You can also solve this question using bit manipulation in Solution 2

Solution
Solution 2