1. 题目

2. 分析

这题要是用Python写,就非常简单了。

3. 代码

class Solution:
    def reverseWords(self, s: str) -> str:
        s = " ".join(reversed(s.strip().split()))
        return s