Search
⌘K

Leetcode 151. Reverse Words in a String

Given a string that may contain leading/trailing/multiple spaces, return a new string with the words in reverse order separated by a single space, removing any extra spaces. Follow-up: do it in-place with O(1) extra space if the string is mutable.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.