I. Problem
Given a string consisted of several words, reverse all words in this string.
Note:
- you need to trim starting & trailing white space
- reduce multiple spaces to only on space between each word
1 | " This is a test string " |
II. Solution
1 | // Test |
III. Complexity
- Time: O(N)
- Space: O(N)