Text Justification
Given an array of words and a maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified.

30:00

Text Justification
hard
Topics
Companies

Given an array of words and a maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified.

Example 1:
Input: {"words":["This","is","an","example","of","text","justification."],"maxWidth":16}
Output: ["This is an","example of text","justification. "]
Constraints:
  • 1words.length3001 \leq \text{words.length} \leq 300

  • 1words[i].length201 \leq \text{words}[i].\text{length} \leq 20

  • words[i] consists of only English letters and symbols.

  • 1maxWidth1001 \leq \text{maxWidth} \leq 100

  • words[i].lengthmaxWidth\text{words}[i].\text{length} \leq \text{maxWidth}

Input
arr ={"words":["This","is","an","example","of","text","justification."],"maxWidth":16}

Justify 7 words with maxWidth=16

Input Words
This
is
an
example
of
text
justification.
Justified Text (maxWidth: 16)

No lines yet...

Words: 7
Max Width: 16
Lines: 0
Variables
No variables to display
DepthFunction Call
Stack empty
0/4