Given a non-negative integer
num
,
write a program to return the number obtained after reversing the bits of
num
.
Problem Note
- The actual binary representation of the number is being considered for reversing the bits, no leading 0’s are being considered.
Example 1
Input: 13
Output: 11
Explanation: Binary representation of 13 is 1101. After reversing the bits we get 1011 which is equal to 11.
Example 2
Input: 6
Output: 3
Explanation: Binary representation of 6 is 110.After reversing the bits we get 011 which is equal to 3.