2*dp 2*bit
This commit is contained in:
20
190-240603-pass/main.py
Normal file
20
190-240603-pass/main.py
Normal 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))
|
Reference in New Issue
Block a user