Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c6d199d

Browse files
author
sejineer
committedMay 22, 2025·
reverse-bits solution
1 parent dbb5ce9 commit c6d199d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎reverse-bits/sejineer.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""
2+
시간 복잡도: O(1)
3+
공간 복잡도: O(1)
4+
"""
5+
class Solution:
6+
def reverseBits(self, n: int) -> int:
7+
result = 0
8+
for _ in range(32):
9+
result <<= 1
10+
result |= n & 1
11+
n >>= 1
12+
return result

0 commit comments

Comments
 (0)
Please sign in to comment.