Share my easy understand python code


  • 0
    F
    class Solution(object):
        def reverseBits(self, n):
            """
            :type n: int
            :rtype: int
            """
            count, rst=0, 0
            while n>0:
                rst=rst*2+n%2
                n/=2
                count+=1
            return rst*(2**(32-count))

Log in to reply
 

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