File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
2
Constraints:
3
- - The input must be a binary string of length 32
4
-
3
+ - The input must be a binary string of length 32
4
+
5
+ <Solution 1>
6
+
5
7
Time Complexity: O(1)
6
- - ํญ์ ๊ณ ์ ๋ 32๋นํธ ๋ฌธ์์ด์ ๋ํด ์ฐ์ฐํ๋ฏ๋ก ์์ ์๊ฐ
8
+ - ํญ์ ๊ณ ์ ๋ 32๋นํธ ๋ฌธ์์ด์ ๋ํด ์ฐ์ฐํ๋ฏ๋ก ์์ ์๊ฐ
7
9
8
10
Space Complexity: O(1)
9
- - 32๋นํธ ๊ณ ์ ํฌ๊ธฐ์ ๋ฌธ์์ด ์ฐ์ฐ๋ง ์ฌ์ฉํ๋ฏ๋ก ์์ ๊ณต๊ฐ
11
+ - 32๋นํธ ๊ณ ์ ํฌ๊ธฐ์ ๋ฌธ์์ด ์ฐ์ฐ๋ง ์ฌ์ฉํ๋ฏ๋ก ์์ ๊ณต๊ฐ
10
12
11
13
ํ์ด ๋ฐฉ๋ฒ:
12
- 1. format(n, '032b')๋ฅผ ์ฌ์ฉํด ์
๋ ฅ๋ฐ์ ์ ์๋ฅผ 32๋นํธ ์ด์ง์ ๋ฌธ์์ด๋ก ๋ณํํจ
13
- 2. ๋ฌธ์์ด ์ฌ๋ผ์ด์ฑ [::-1]์ผ๋ก ๋นํธ๋ฅผ ๋ค์ง์
14
- 3. int(reversed_binary, 2)๋ก ๋ค์ง์ ์ด์ง์ ๋ฌธ์์ด์ ๋ค์ ์ ์๋ก ๋ณํํจ
14
+ 1. format(n, '032b')๋ฅผ ์ฌ์ฉํด ์
๋ ฅ๋ฐ์ ์ ์๋ฅผ 32๋นํธ ์ด์ง์ ๋ฌธ์์ด๋ก ๋ณํํจ
15
+ 2. ๋ฌธ์์ด ์ฌ๋ผ์ด์ฑ [::-1]์ผ๋ก ๋นํธ๋ฅผ ๋ค์ง์
16
+ 3. int(reversed_binary, 2)๋ก ๋ค์ง์ ์ด์ง์ ๋ฌธ์์ด์ ๋ค์ ์ ์๋ก ๋ณํํจ
15
17
"""
16
18
17
19
class Solution :
@@ -22,3 +24,12 @@ def reverseBits(self, n: int) -> int:
22
24
reversed_binary = binary [::- 1 ]
23
25
24
26
return int (reversed_binary , 2 )
27
+ """
28
+ <Solution 2>
29
+
30
+ Time Complexity:
31
+
32
+ Space Complexity:
33
+
34
+ ํ์ด ๋ฐฉ๋ฒ:
35
+ """
You canโt perform that action at this time.
0 commit comments