We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cbeb594 commit e54ac6aCopy full SHA for e54ac6a
reverse-bits/yyyyyyyyyKim.py
@@ -0,0 +1,11 @@
1
+class Solution:
2
+ def reverseBits(self, n: int) -> int:
3
+
4
+ answer = 0
5
6
+ for i in range(32):
7
+ answer <<= 1 # 왼쪽으로 한 칸 밀어서 자리 확보
8
+ answer |= (n&1) # n의 마지막 비트 추출해서 answer 맨 뒤에 추가
9
+ n >>= 1 # n 오른쪽으로 한 칸 밀기
10
11
+ return answer
0 commit comments