Algorithm · C3.ai · Hard
You receive a body of text along with a maximum line width measured in columns. Arrange the words of the text into lines so that no line exceeds that width and the total number of lines is as small as it can be. Within each line, distribute the space characters between adjacent words so that the gaps are as close to equal in size as possible. The last line is an exception: it should not be justified in this way. Examples Example 1 Example 2