Skip to content

Commit ce6f875

Browse files
Solve : Reverse Bits
1 parent d0d3502 commit ce6f875

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

reverse-bits/printjin-gmailcom.py

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

0 commit comments

Comments
 (0)