Leetcode習題反轉字串 阿新 • • 發佈:2021-01-30 技術標籤:力扣pythonleetcode python反轉字串 class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ l=0 r=len(s)-1 while l<r: s[l],s[r]=s[r],s[ l] l+=1 r-=1 python反轉字串III class Solution(object): def reverseWords(self, s): return " ".join(s.split(" ")[::-1])[::-1]