Medium · Strings
Reverse Words in a String
Given a string s of words separated by one or more spaces (possibly with leading or trailing spaces), return its words in reverse order joined by single spaces, with no spaces at either end.
Examples
Example 1
{
"s": "the sky is blue"
}Output: "blue is sky the"
Example 2
{
"s": " hello world "
}Output: "world hello"
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.