Reverse Words in a String
Words in s are separated by one or more spaces, and s may have spaces at the start or the end.
Return a string with the words in reverse order, joined by exactly one space and with no extra spaces at the start or the end. The letters inside each word keep their order.
Example 1
s "the sky is blue"
returns "blue is sky the"
The words in reverse order: blue is sky the.
Example 2
s " hi there "
returns "there hi"
Extra spaces are dropped: there hi.
Constraints
1 <= len(s) <= 100shas letters and spaces and at least one word
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.