Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 369 Bytes

190.md

File metadata and controls

29 lines (20 loc) · 369 Bytes

Reverse Bits

Description

link


Solution

See Code


Code

O(n)

class Solution:
    # @param n, an integer
    # @return an integer
    def reverseBits(self, n):
        res = 0
        for _ in xrange(32):
            res = (res<<1) + (n&1)
            n>>=1
        return res