Files
leetcode/151-reverse-words-in-a-string/151-reverse-words-in-a-string.py
T

5 lines
139 B
Python

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