You are given a string
text
of words that are placed among some number of spaces. Each word consists of one or more lowercase English letters and are separated by at least one space. It's guaranteed that text
contains at least one word.Rearrange the spaces so that there is an equal number of spaces between every pair of adjacent words and that number is maximized. If you cannot redistribute all the spaces equally, place the extra spaces at the end, meaning the returned string should be the same length as
text
.Return the string after rearranging the spaces.
Example 1:
Example 2:
Constraints:
1 <= text.length <= 100
text
consists of lowercase English letters and' '
.
text
contains at least one word.
풀이
은찬
효성
아니! 제 풀이 마음에 안들어요!
그래서 짧은 풀이 훔쳐왔어요.