思路1 贪心 遍历words

  • 时间复杂度 $O(n)$

  • 空间复杂度 $O(n)$

第一次遍历,把 words 按 line 分好 第二次遍历,加空格组成字符串, 注意最后一行 left justify

Last updated