151_Reverse Words in a String
Test case 1 (easy)
Input: "the weather is good"
Output: "good is weather the"Test case 2 (with spaces at the beginning and the end)
Input: " the weather is good "
Output: "good is weather the"Test case 3 (only spaces in the string)
Input: " "
Output: ""Test case 4 (empty string)
Input: ""
Output: ""Test case 5 (more than one space between words)
Idea 1
Complexity 1
Solution 1_v1 (with build-in functions split(), reverse(), join())
Solution 1_v2 (write split(), use build in reverse(), join())
Idea 2
Complexity 2
Solution 2
Idea 3
Complexity 3
Last updated