赞
踩
class Solution:
def fullJ(self,words: List[str],maxWidth: int)-->List[str]:
res,linecache,counter=[],[],0
for word in words:
if counter+len(word)+len(line)>maxWidth:
for i in range(maxWidth - counter):
line[i%max(len(line)-1,1)]+=''
res.append((''.join(line)))
line,counter=[],0
line +=[word]
counter+=len(word)
return res + [''.join(line).ljust(maxWidth)]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。