Simple C++ DP solution with Explanation
```\nclass Solution {\npublic:\n    int MAX = 1000;\n    int palindromePartition(string s, int k) {\n        \n        //Compute min substitutions required to m
```\nclass Solution {\npublic:\n    int MAX = 1000;\n    int palindromePartition(string s, int k) {\n        \n        //Compute min substitutions required to make (i, j) a palindrome for all i, j\n        // min Substitutions to make k palindromes upto n = \n        //min Substitutions to make k-1 palindromes upto (0..j.n-1) \n        //+ min substitutions required to make (j to n-1) a palindrome\n        \n        int n = s.size();\n        vector<vector<int>> subs (n,vector<int>(n,0));\n        vector<vector<int>> dp (k+1, vector<int>(n, MAX));\n        \n        for (int i=0 ; i<n; i++) subs[i][i] =0;\n        for (int i=0 ; i<n-1; i++) subs[i][i+1] = (int) not (s.substr(i,1) == s.substr(i+1,1));\n        \n        for (int l=2; l <n ; l++){\n            for (int i=0 ; i < n-l ; i++ ){\n                int j=i+l ; \n                subs[i][j] = subs[i+1][j-1] + (int) not (s.substr(i,1) == s.substr(j,1));\n            }\n        }\n        \n        \n        for (int j=0; j < n ; j++) dp[0][j] = 0 ;\n        for (int j=0 ; j <n ; j++) dp[1][j] = subs[0][j];\n        for (int i=2; i <=k ; i++ ){\n            for (int j=0; j<n ; j++){\n                int min_subs = MAX;\n                for (int l= 0; l < j ; l++){\n                    min_subs = min (min_subs, dp[i-1][l] + subs[l+1][j]);\n                }\n                dp[i][j] = min_subs;\n            }\n        }\n        \n        \n        return dp[k][n-1];        \n        \n    }\n};
[]