1
class Solution(object):
2
def reorderSpaces(self, text):
3
word_list = text.split()
4
words, spaces = len(word_list), text.count(" ")
5

6
if words > 1:
7
q, r = spaces // (words - 1), spaces % (words - 1)
8
return (" " * q).join(word_list) + " " * r
9
else:
10
return "".join(word_list) + " " * spaces

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0