21 lines
431 B
Python
21 lines
431 B
Python
class Solution:
|
|
def reverseBits(self, n: int) -> int:
|
|
num = n
|
|
l = []
|
|
while num != 0:
|
|
l.append(num % 2)
|
|
num //= 2
|
|
rlt = 0
|
|
length = len(l)
|
|
while len(l) < 32:
|
|
l.append(0)
|
|
print(l)
|
|
l.reverse()
|
|
for i, n in enumerate(l):
|
|
rlt += n * pow(2, i)
|
|
return rlt
|
|
|
|
|
|
sol = Solution()
|
|
print(sol.reverseBits(43261596))
|