@@ -0,0 +1,1273 @@
+package coding4fun;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0A/**%0A * Given a list of characters, generate a possible ways to parenthesize the characters.%0A *%0A * %3Cpre%3E%0A * Input : %5Ba, b%5D%0A * Output: %5B(a, b)%5D%0A *%0A * Input : %5Ba, b, c%5D%0A * Output: %5B(a(bc)), ((ab)c)%5D%0A *%0A * Input : %5Ba, b, c%5D%0A * Output: %5B(a(b(cd))), (a((bc)d)), ((ab)(cd)),%0A *          ((a(bc))d), (((ab)c)d)%5D%0A * %3C/pre%3E%0A */%0Apublic class Problem21 %7B%0A    private static List%3CString%3E generate(List%3CString%3E list) %7B%0A        List%3CString%3E result = new ArrayList%3C%3E();%0A        for (int i = 0; i %3C list.size()-1; i++) %7B%0A            List%3CString%3E left = generate(list.subList(0, i+1));%0A            List%3CString%3E right = generate(list.subList(i+1, list.size()));%0A            for (String l : left) %7B%0A                for (String r : right) %7B%0A                    result.add(%22(%22 + l + r + %22)%22);%0A                %7D%0A            %7D%0A        %7D%0A        if (result.isEmpty()) %7B%0A            result.addAll(list);%0A        %7D%0A        return result;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        System.out.println(generate(Arrays.asList(%22a%22, %22b%22)));%0A        System.out.println(generate(Arrays.asList(%22a%22, %22b%22, %22c%22)));%0A        System.out.println(generate(Arrays.asList(%22a%22, %22b%22, %22c%22, %22d%22)));%0A    %7D%0A%7D%0A

Add problem 21