line is made of words (lowercase English letters) and spaces; words are separated by at least one space, and there may be spaces at either end. The line contains at least one word.
Move the spaces around so that the words stay in their original order, every two neighboring words have the same number of spaces between them, and that number is as large as possible. Any spaces that cannot be shared out evenly go to the end of the line, so the result has the same length as line.
Return the resulting string.line=" red fox jumps" → 'red fox jumps '
There are 5 spaces, 3 words and 2 gaps: 2 spaces per gap, and the one left over goes to the end.
line=" solo " → 'solo '
There is only one word and no gaps, so all 3 spaces go to the end.
line consists of lowercase English letters and spacesline contains at least one wordline=" red fox jumps"
'red fox jumps '
Run checks the first 3 tests in your browser. Submit checks all 133 tests on the server, hidden ones included.