2*dp 2*bit

This commit is contained in:
2024-06-03 17:50:37 +02:00
parent cdb6cccb89
commit bccc78b194
4 changed files with 82 additions and 0 deletions

20
190-240603-pass/main.py Normal file
View File

@@ -0,0 +1,20 @@
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))