Skip to content

Commit 6295808

Browse files
committed
Improved task
1 parent e469390 commit 6295808

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/main/java/g0001_0100/s0068_text_justification/Solution.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,8 @@ public List<String> fullJustify(String[] words, int maxWidth) {
4444
sb.append(' ');
4545
}
4646
// appending the rest of the required spaces
47-
sb.append(
48-
" "
49-
.repeat(
50-
Math.max(
51-
0,
52-
(maxWidth - lineTotal)
53-
/ (numWordsOnLine - 1))));
47+
int max = Math.max(0, (maxWidth - lineTotal) / (numWordsOnLine - 1));
48+
sb.append(" ".repeat(max));
5449
}
5550
// appending the last word of the line
5651
sb.append(words[startWord + numWordsOnLine - 1]);

0 commit comments

Comments
 (0)