Skip to content

Commit 1f414e9

Browse files
committed
Create 344. Reverse String.py
1 parent c07415b commit 1f414e9

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

344. Reverse String.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
# @Time : 2019/2/28 9:57
3+
# @Author : xulzee
4+
5+
# @File : 344. Reverse String.py
6+
# @Software: PyCharm
7+
from typing import List
8+
9+
10+
class Solution:
11+
def reverseString1(self, s: List[str]) -> None:
12+
"""
13+
Do not return anything, modify s in-place instead.
14+
"""
15+
s.reverse()
16+
17+
def reverseString(self, s: List[str]) -> None:
18+
"""
19+
Do not return anything, modify s in-place instead.
20+
"""
21+
l = len(s)
22+
for i in range((l - 1) // 2 + 1):
23+
s[i], s[l - i - 1] = s[l - i - 1], s[i]
24+
25+
26+
if __name__ == '__main__':
27+
A = [2, 7, 11, 15]
28+
Solution().reverseString(A)
29+
print(A)

0 commit comments

Comments
 (0)