Reverse Bits

Reverse bits of an 32 bit unsigned integer

Example 1:

x = 0,

          00000000000000000000000000000000  
=>        00000000000000000000000000000000

return 0

Example 2:

x = 3,

          00000000000000000000000000000011 
=>        11000000000000000000000000000000

return 3221225472

Since java does not have unsigned int, use long

Interview Code Editor
Hints
  • Hint 1
  • Solution Approach
  • Complete Solution
6974 successful submissions.
Asked In:
  • Nvidia
  • HCL
  • Amazon
Click here to jump start your coding interview preparation