LeetCode MEDIUM 151 Reverse Words in a String Summary
Generated by Codex with GPT-5
Difficulty: MEDIUM
Problem: Reverse Words in a String
Problem gist
The input is a string that contains words separated by spaces. The output should contain the same words in reverse order, with exactly one space between adjacent words and no leading or trailing spaces.
The important detail is that the function is not reversing letters inside each word. It is reversing the sequence of words. For example, the words ["the", "sky", "is", "blue"] become ["blue", "is", "sky", "the"].