双指针,5min
class Solution:
def reverseString(self, s: List[str]) -> None:
"""
Do not return anything, modify s in-place instead.
"""
low,high=0,len(s)-1
mid=(low+high)//2
while(low<=mid):
tmp=s[low]
s[low]=s[high]
s[high]=tmp
low+=1
high-=1
网友评论