very Pythonic solution


  • 0
    J
    class Solution:
        # @param n, an integer
        # @return an integer
        def reverseBits(self, n):
            t = bin(n)[2:]
            t = (32-len(t))*'0' + t
            return int(t[::-1],2)
    

Log in to reply
 

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