Skip to content

Latest commit

 

History

History
13 lines (12 loc) · 290 Bytes

53. 颠倒二进制位.md

File metadata and controls

13 lines (12 loc) · 290 Bytes

颠倒给定的 32 位无符号整数的二进制位。

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