reverse_bits

  • 2022-12-14
  • 浏览 (643)

reverse_bits.py 源码

# 颠倒二进制位


class Solution:
    def reverseBits(self, n: int) -> int:
        res, power = 0, 31
        while n:
            print(n)
            res += (n & 1) << power
            n = n >> 1
            power -= 1
        return res

你可能感兴趣的文章

best_time_buy_sell_stock

best_time_buy_sell_stock_ii

climb_statirs

0  赞