Text Justification
Hard · Phone screen · Onsite · Full-time
Text justification. Pack words into lines of exactly maxWidth characters, distributing extra spaces evenly with a left bias. The last line is left-justified. I processed words greedily, filling each line as much as possible, then calculated spacing. Getting the space distribution right with integer division and remainders was the tedious part. The interviewer appreciated that I handled the last-line edge case cleanly.
