Lay out the list of words words as lines of text, each exactly maxWidth characters wide, the way a newspaper column lines up on both edges. Return the lines in order.
maxWidth characters by widening the gaps between its words. Share the spaces as evenly as possible. When they don't divide evenly, the gaps on the left get one more space than the gaps on the right.Pack as many is exactly 12 characters, so its gaps stay at one space. fit. won't fit after words as, so that line's 5 spare spaces all go into its only gap. fit. is the last line: it stays on the left, padded on the right.
The first line has 3 spaces for 2 gaps, so the left gap gets 2 and the right gap gets 1.
Extraordinary is alone on its line, so it sits on the left with one space after it.
Constraints
1 <= words.length <= 3001 <= words[i].length <= 20words[i] is made of English letters and the punctuation marks . ! ? ; : ' -.1 <= maxWidth <= 100words[i].length <= maxWidthHandle one line at a time: first decide which words go on it, then lay out the spaces.