diff --git a/java/0068-text-justification.java b/java/0068-text-justification.java new file mode 100644 index 000000000..3871ad1ca --- /dev/null +++ b/java/0068-text-justification.java @@ -0,0 +1,64 @@ +class Solution { + int MAX_WIDTH; + + public List fullJustify(String[] words, int maxWidth) { + List result = new ArrayList<>(); + int n = words.length; + MAX_WIDTH = maxWidth; + int i = 0; + + while(i 0) { + sb.append(" "); + extraSpace--; + } + } + + while(sb.length() < MAX_WIDTH) { + sb.append(" "); + } + + return sb.toString(); + } +} \ No newline at end of file