Java Recursion DP with Memorization
\n```    \n\npublic int palindromePartition(String s, int k) {\n        Integer[][] dp = new Integer[k + 1][s.length() + 1];\n        return palindromePartition
\n```    \n\npublic int palindromePartition(String s, int k) {\n        Integer[][] dp = new Integer[k + 1][s.length() + 1];\n        return palindromePartition(s.toCharArray(), k, 0, dp);\n    }\n\n    public int palindromePartition(char[] chars, int k, int index, Integer[][] dp) {\n        if (dp[k][index] != null) {\n            return dp[k][index];\n        }\n\n        if (k == 1) {\n            return countMinChanges(chars, index, chars.length - 1);\n        }\n\n        int minChanges = Integer.MAX_VALUE;\n        for (int i = index; i < chars.length - k + 1; i++) {\n            int first = countMinChanges(chars, index, i);\n            int second = palindromePartition(chars, k - 1, i + 1, dp);\n            minChanges = Math.min(minChanges, first + second);\n        }\n        dp[k][index] = minChanges;\n        return minChanges;\n    }\n\n    private int countMinChanges(char[] chars, int i, int j) {\n        int minChanges = 0;\n        while (i < j) {\n            if (chars[i] != chars[j]) {\n                minChanges++;\n            }\n            i++;\n            j--;\n        }\n        return minChanges;\n    }
[]