题目1
题解1
class Solution:
def reverseBits(self, n: int) -> int:
ans = 0
i = 32
# 循环移动32次
while i > 0:
# 向左移动
ans <<= 1
# 移动后将末尾加n的尾部值
ans += n&1
# 跟新n值,以取到最后的值
n >>= 1
i -= 1
return ans