We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e92eb77 commit dce5aa9Copy full SHA for dce5aa9
1 file changed
python/string/leetcode_344.py
@@ -0,0 +1,20 @@
1
+# LeetCode
2
+# 344. Reverse String
3
+# https://leetcode.com/problems/reverse-string/
4
+
5
+def mySolution(s: [str]) -> None:
6
+ # 그냥 뒤집는 방법
7
+ s.reverse()
8
9
+ # 공간복잡도가 O(1)이기 때문에 해당 상황을 고려한 방벙
10
+ s[:] = s[::-1]
11
12
+def twoPointersSolution(s: [str]) -> None:
13
+ # 투 포인터 사용
14
+ left = 0
15
+ right = len(s)-1
16
17
+ while left < right:
18
+ s[left], s[right] = s[right], s[left]
19
+ left += 1
20
+ right -= 1
0 commit comments