Last Updated: 29 Aug, 2025

Normalize Sentence Spacing

Easy

Problem statement

You are given a string s, which may contain words, extra spaces between words, and leading or trailing spaces.

Your task is to reformat the string to a "normalized" version. A normalized string has all its words separated by exactly one space, with no spaces at the beginning or end of the string.


Input Format:
The first line of input contains a single string s.


Output Format:
Print the reformatted string on a single line.


Note:
A "word" is defined as any sequence of non-space characters.

If the input string is empty or contains only spaces, the output should be an empty string.