Multiple spaces
Input
split_and_join(' Hello world ')
Output
Hello world
Splitting removes extra whitespace, joining with default single space gives 'Hello world'.
Full lesson preview
Split a sentence on whitespace into words and rejoin them with a given delimiter.
Problem statement
Task
Examples
Input
split_and_join(' Hello world ')
Output
Hello world
Splitting removes extra whitespace, joining with default single space gives 'Hello world'.
Input
split_and_join('one\ttwo\nthree', ',')
Output
one,two,three
Tabs/newlines are treated as separators; join with comma.
Input format
Output format
Constraints
Samples
Input
split_and_join(' a b c ')
Output
a b c
Extra spaces collapsed and words joined with a single space.