This question evaluates practical programming skills in string processing, greedy packing, and careful handling of spacing and edge cases, and falls under the Coding & Algorithms domain.
You are given a list of words (strings with no spaces) and an integer maxWidth.
Implement text formatting in two variants:
Return lines by packing words greedily from left to right:
Return lines of exactly maxWidth characters:
maxWidth
.
maxWidth
.
maxWidth
.
words: List[str]
maxWidth: int
List[str]
lines formatted according to the chosen variant.
1 <= len(words) <= 10^4
1 <= len(words[i]) <= maxWidth
1 <= maxWidth <= 100