Skip to content

Commit e2a74d0

Browse files
committed
reverse-bits solution
1 parent 4c8b68f commit e2a74d0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

reverse-bits/sungjinwi.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def reverseBits(self, n: int) -> int:
3+
ret = 0
4+
for _ in range(31) :
5+
ret |= n & 1
6+
ret <<= 1
7+
n >>= 1
8+
ret += n & 1
9+
return ret

0 commit comments

Comments
 (0)