Tidy the Spaces
Collapse every run of spaces to a single space and strip leading/trailing spaces.
Input: one line of words separated by arbitrary numbers of spaces (possibly leading/trailing).
Output: the tidied line.
Constraints:
- 1 ≤ length ≤ 104
- at least one word
Sample Tests
Input 1
hello world
Output 1
hello world
Input 2
a b
Output 2
a b
Discussion (opens after you solve — no spoilers before)
No comments yet.