Removing Extra Spaces
TypeScript
Easy
strings
Task «Removing Extra Spaces»
Write a program that takes a string containing words separated by one or more spaces. It is necessary to remove extra spaces: leave only one space between words, and also remove all leading and trailing spaces. Output the resulting string.
Input Format
One line consisting of letters of the Latin alphabet and spaces. The length of the string does not exceed 1000 characters.
Output Format
One line — the original string without extra spaces.
Examples
Example 1
INPUT
hello world
OUTPUT
hello world
Example 2
INPUT
6
1 2 -5 4 3 -1
3
OUTPUT
6
Example 3
INPUT
multiple spaces
OUTPUT
multiple spaces
Example 4
INPUT
4
-2 -3 -1 -4
2
OUTPUT
4
main.ts