Bottom up dp self explanatory ,easy to understand.
class Solution {\npublic:\n    int palindromePartition(string s, int k) {int l,r,n=s.length();\n        vector>dp1(n,vector(n)),dp(n,vector(k+1,n+1));\n        
class Solution {\npublic:\n    int palindromePartition(string s, int k) {int l,r,n=s.length();\n        vector<vector<int>>dp1(n,vector<int>(n)),dp(n,vector<int>(k+1,n+1));\n        for(l=n-1;l>=0;l--)\n        {\n            for(r=l;r<n;r++)\n                dp1[l][r]=(s[l]!=s[r])+((l+1<r)?dp1[l+1][r-1]:0);\n        }\n        for(r=0;r<n;r++)\n        {\n            for(int cnt=1;cnt<=k;cnt++)\n            {\n                if(r+1<cnt)\n                    continue;\n                if(cnt==1)\n                {\n                    dp[r][cnt]=dp1[0][r];\n                    continue;\n                }\n                for(l=0;l<=r;l++)\n                        dp[r][cnt]=min(dp[r][cnt],dp1[l][r]+(l?dp[l-1][cnt-1]:0));\n            }\n        }return dp[n-1][k];\n    }\n};
[]