← ALL NOTES
Two Pointers

151. Reverse Words in a String

Reverse the word order in a string, collapsing any leading, trailing, or repeated spaces down to single separators. The lazy solution — split on whitespace, reverse the vector, join — works fine, but…

Loading…