- 小周版本
class Solution:
def reverseString(self, s: List[str]) -> None:
"""
Do not return anything, modify s in-place instead.
"""
i=0
j=len(s)-1
while (i<j):
temp=s[i]
s[i]=s[j]
s[j]=temp
i=i+1
j=j-1
- 小刘版本
class Solution:
def reverseString(self, s: List[str]) -> None:
"""
Do not return anything, modify s in-place instead.
"""
n=len(s)
m=int(n/2)
for i in range(0,m):
a=s[i]
s[i]=s[n-1-i]
s[n-1-i]=a