As reported: ServiceNow Staff Software Engineer loop, round 1, Feb 2026: Text Justification.
Given words and maxWidth, format the text so each line has exactly maxWidth characters:
- Pack as many words as fit on each line greedily (one space minimum between words).
- Distribute extra spaces between words as evenly as possible; when they do not divide evenly, the gaps on the left get more.
- A line with a single word is left-justified and padded with spaces on the right.
- The last line is left-justified: single spaces between words, padding on the right.
This is LeetCode 68 — Text Justification.
Example
words = ["This","is","an","example","of","text","justification."], maxWidth = 16
->
["This is an",
"example of text",
"justification. "]
Constraints: 1 ≤ words.length ≤ 300; 1 ≤ words[i].length ≤ maxWidth ≤ 100; words have no spaces.
Code runner format: line 1 words, line 2 maxWidth. Implement fullJustify(words, maxWidth); the harness prints the list of lines.