My Python 56ms Answer


  • 0
    S
    class Solution(object):
    def reverseBits(self, n):
        """
        :type n: int
        :rtype: int
        """
        newnum = 0
        l = 31
        while l >= 0:
            res = n % 2
            if res == 1:
                newnum += 2 ** l 
            n /= 2
            l -= 1
        return newnum

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.