【LeetCode 151】反转字符串中的单词
1. 题目
2. 分析
这题要是用Python写,就非常简单了。
3. 代码
class Solution:def reverseWords(self, s: str) -> str:s = " ".join(reversed(s.strip().split()))return s
这题要是用Python写,就非常简单了。
class Solution:def reverseWords(self, s: str) -> str:s = " ".join(reversed(s.strip().split()))return s