ans to store the justified text, and an index i to keep track of the current word.i is less than the length of words, repeat the following steps:
a. Call getWords(i) to determine the words that fit on the current line and store them in currentLine.
b. Increment i by the length of currentLine.
c. Call createLine(currentLine, i) to format the line according to the justification rules and add the result to ans.ans as the final justified text.