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 11"""
22Constraints:
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+
57Time Complexity: O(1)
6- - ํญ์ ๊ณ ์ ๋ 32๋นํธ ๋ฌธ์์ด์ ๋ํด ์ฐ์ฐํ๋ฏ๋ก ์์ ์๊ฐ
8+ - ํญ์ ๊ณ ์ ๋ 32๋นํธ ๋ฌธ์์ด์ ๋ํด ์ฐ์ฐํ๋ฏ๋ก ์์ ์๊ฐ
79
810Space Complexity: O(1)
9- - 32๋นํธ ๊ณ ์ ํฌ๊ธฐ์ ๋ฌธ์์ด ์ฐ์ฐ๋ง ์ฌ์ฉํ๋ฏ๋ก ์์ ๊ณต๊ฐ
11+ - 32๋นํธ ๊ณ ์ ํฌ๊ธฐ์ ๋ฌธ์์ด ์ฐ์ฐ๋ง ์ฌ์ฉํ๋ฏ๋ก ์์ ๊ณต๊ฐ
1012
1113ํ์ด ๋ฐฉ๋ฒ:
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)๋ก ๋ค์ง์ ์ด์ง์ ๋ฌธ์์ด์ ๋ค์ ์ ์๋ก ๋ณํํจ
1517"""
1618
1719class Solution :
@@ -22,3 +24,12 @@ def reverseBits(self, n: int) -> int:
2224 reversed_binary = binary [::- 1 ]
2325
2426 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