# Easy
如果list长度是偶数,则len(s)/2作为index是中间偏前一位
len(s)/2
index
如果list长度是奇数,则len(s)/2作为index是中间那位
class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ l = len(s) for i in range(l//2): tmp = s[i] s[i] = s[l-i-1] s[l-i-1] = tmp
Last updated 4 years ago
Was this helpful?