Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Text Justification

Format a list of words into lines of exactly maxWidth characters with full justification: pack as many words per line as possible, distribute extra spaces as evenly as possible between words (extra spaces go to the left slots), left-justify the last line and any line with a single word, and pad with spaces on the right. Print each line.

Constraints

1 <= n <= 300 1 <= len(word) <= maxWidth <= 100

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.