151. Reverse Words in a String
https://leetcode.com/problems/reverse-words-in-a-string/
Python
Stack on empty check
class Solution:
def reverseWords(self, s: str) -> str:
words = []
for word in s.split(' ')[::-1]:
if word:
words.append(word)
return ' '.join(words)