@@ -0,0 +1,2201 @@
+/**%0A * Problem Link: https://leetcode.com/problems/text-justification/%0A * %0A * Really took me some time to cover every cases.%0A */%0Apublic class Solution %7B%0A    public List%3CString%3E fullJustify(String%5B%5D words, int maxWidth) %7B%0A        List%3CString%3E list = new ArrayList%3CString%3E();%0A        int start = -1;%0A        int length = 0;%0A        for(int i=0; i%3Cwords.length; i++) %7B%0A            if(start == -1) %7B%0A                start = i;%0A                length = 0;%0A            %7D%0A            if(length + words%5Bi%5D.length() + (i - start) %3E maxWidth) %7B%0A                int count = i - start;%0A                int space = (maxWidth - length) / (count == 1 ? 1 : count - 1);%0A                int mod = (maxWidth - length) %25 (count == 1 ? 1 : count - 1);%0A                int total = maxWidth - words%5Bstart%5D.length();%0A                String ret = words%5Bstart++%5D;%0A                String spaceS = %22%22;%0A                while(space--%3E0) spaceS+=%22 %22;%0A%0A                for(;start %3C i; start++) %7B%0A                    ret += (mod %3E 0 ? %22 %22 : %22%22) + spaceS + words%5Bstart%5D;%0A                    total -= words%5Bstart%5D.length() + spaceS.length();%0A                    if(mod %3E 0) total --;%0A                    mod --;%0A                %7D%0A                if(total %3E 0) %7B%0A                    for(int k=0; k%3Ctotal; k++)%0A                        ret += %22 %22;%0A                %7D%0A                start = -1;%0A                list.add(ret);%0A                i--;%0A            %7D else %7B%0A                length += words%5Bi%5D.length();%0A                if(i == words.length - 1) %7B%0A                    int count = i - start + 1;%0A                    int space = maxWidth - words%5Bstart%5D.length();%0A                    String ret = words%5Bstart++%5D;%0A                    %0A                    for(;start %3C words.length; start++) %7B%0A                        ret += %22 %22 + words%5Bstart%5D;%0A                        space -= words%5Bstart%5D.length() + 1;%0A                    %7D%0A                    %0A                    if(space %3E 0) %7B%0A                        for(int k=0; k%3Cspace; k++)%0A                            ret += %22 %22;%0A                    %7D%0A                    start = -1;%0A                    list.add(ret);%0A                %7D%0A            %7D%0A        %7D%0A        return list;%0A    %7D%0A%7D%0A

Create Text_Justification.java