Reverse Bits

Given a non-negative integer numwrite a program to return the number obtained after reversing the bits of num.

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.

Solution In Python

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top