@@ -0,0 +1,1314 @@
+package leetcode;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * https://leetcode.com/problems/palindrome-partitioning/%0A */%0Apublic class Problem131 %7B%0A    public List%3CList%3CString%3E%3E partition(String s) %7B%0A        List%3CList%3CString%3E%3E result = new ArrayList%3C%3E();%0A        List%3CString%3E accu = new ArrayList%3C%3E();%0A        partition(s, accu, result);%0A        return result; %0A    %7D%0A    %0A    private void partition(String s, List%3CString%3E accu, List%3CList%3CString%3E%3E result) %7B%0A        if (s.length() == 0) %7B%0A            result.add(accu);%0A            return;%0A        %7D%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            String leftSubstr = s.substring(0, i+1);%0A            if (!isPalindrome(leftSubstr)) %7B%0A                continue;%0A            %7D else %7B%0A                List%3CString%3E newAccu = new ArrayList%3C%3E(accu);%0A                newAccu.add(leftSubstr);%0A                String rightSubstr = s.substring(i+1);%0A                partition(rightSubstr, newAccu, result);%0A            %7D%0A        %7D%0A    %7D%0A    %0A    private boolean isPalindrome(String s) %7B%0A        char%5B%5D chars = s.toCharArray();%0A        int left = 0;%0A        int right = s.length() - 1;%0A        while (left %3C right) %7B%0A            if (chars%5Bleft++%5D != chars%5Bright--%5D) %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%7D%0A

Solve problem 131