【leetcode❤python】 190. Reverse Bits

#-*- coding: UTF-8 -*-
class Solution:
    # @param n, an integer
    # @return an integer
    def reverseBits(self, n):
        tmp=str(bin(n))[2:][::-1]
        
        for i in xrange(32-len(tmp)):
            tmp+='0'
       
        return int(tmp,base=2)

sol=Solution()
print sol.reverseBits(43261596)

posted @ 2016-11-13 19:23  火金队长  阅读(216)  评论(0编辑  收藏  举报