Given an input string s, reverse the order of the words.
A word is defined as a sequence of non-space characters. The words in s will be separated by one space for simplicity.
Return a string of the words in reverse order concatenated by a single space.
Example:
Input: input = "sky is blue" Output: "blue is sky"
Walkthroughs of the solution. Try the steps first, then watch to compare approaches.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check