Given a string s, reverse the order of the words in the string while keeping the individual words unchanged. Words are separated by spaces.
Note: The output string should have words separated by a single space, with no extra spaces at the beginning or end.
Example 1
Input: s = "practice makes perfect"
Output: "perfect makes practice"
Explanation: After reversing the order of the words and trimming spaces, the result is "perfect makes practice".
Example 2
Input: s = "here spaces multiple"
Output: "multiple spaces here"
Explanation: After reversing the words, the result is "multiple spaces here".
Sign in to write, run, and submit your solution against the full test suite.