Given an unsigned 32-bit integer n, return the unsigned integer produced by reversing its bit order. Bit 0 becomes bit 31, bit 1 becomes bit 30, and so on. Implement a function that operates on exactly 32 bits.
Constraints
0 <= n <= 2^32 - 1
Treat n as an unsigned 32-bit integer
The solution must reverse exactly 32 bits
Function Signature
defreverse_bits(n):
Interviewer
Your question is Reverse Bits of Integer. Start with the requirements in the Question tab.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.