1.反转字符串https://leetcode-cn.com/problems/reverse-string/
一开始没想到,看了解答才恍然大悟原来这么简单
双指针法
1 class Solution: 2 def reverseString(self, s: List[str]) -> None: 3 """ 4 Do not return anything, modify s in-place instead. 5 """ 6 for i in range(len(s)//2): 7 tmp = s[i] 8 s[i] = s[len(s)-i-1] 9 s[len(s)-i-1] = tmp
时间复杂度65.6%
2.翻转字符串中的单词 IIIhttps://leetcode-cn.com/problems/reverse-words-in-a-string-iii/