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 b87ce6f commit bb53e35Copy full SHA for bb53e35
reverse-bits/samthekorean.py
@@ -0,0 +1,9 @@
1
+# TC : O(1)
2
+# SC : O(1)
3
+# Reason : The input is fixed to be 32 bit resulting in time and space complexity being O(1)
4
+class Solution:
5
+ def reverseBits(self, n: int) -> int:
6
+ binary_string = bin(n)[2:].zfill(32)
7
+ reversed_binary_string = binary_string[::-1]
8
+
9
+ return int(reversed_binary_string, 2)
0 commit comments