Fixed-Width Text Formatter
Asked at Airbnb
Reported by the problem's creator, not verified
You are laying text out for a display with a fixed character width. Write format_text, which returns the layout as a list of strings.
Examples
Example 1
Input: text =
this is a article, width =10Output:
["this is a ","article "]Explanation:
this is atakes 9 characters, and addingarticlewould make 17, so the line is closed and padded with one space.articleis 7 characters and is padded with 3 spaces.
Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.