---
# System prepended metadata

title: Leetcode 151.

---

# Leetcode 151. Reverse Words in a String

## 題解

split -> reverse -> join

```python
class Solution:
    def reverseWords(self, s: str) -> str:
        def split_without_empty_string(string):
            return [x for x in string.split(" ") if x]
        return " ".join(split_without_empty_string(s)[::-1])
```
