c++ solution | Simple DP (memoization)|
\nclass Solution {\npublic:\n    int check(string &s){\n        int i=0,j=s.size()-1;int cnt=0;\n        while(i<j){\n            if(s[i++]!=s[j--]){\n         
```\nclass Solution {\npublic:\n    int check(string &s){\n        int i=0,j=s.size()-1;int cnt=0;\n        while(i<j){\n            if(s[i++]!=s[j--]){\n                cnt++;\n            }\n        }\n        return cnt;\n    }\n    vector<vector<int>> dp;\n    int solve(string& s,int i,int k){\n        int n=s.size();\n        if(k<0)return INT_MAX;\n        if((n-i)<k)return INT_MAX;\n        if(i==n and k==0)return 0;\n        if(dp[i][k]!=-1)return dp[i][k];\n        string curr="";\n        long long ans=INT_MAX;\n        for(int j=i;j<n;j++){\n            curr.push_back(s[j]);\n            long long cnt=solve(s,j+1,k-1);\n            if(cnt<ans){\n                long long len=(check(curr));\n                ans=min(ans,len+cnt);\n            }\n        }\n        return dp[i][k]=int(ans);\n    }\n    int palindromePartition(string& s, int k) {\n        int n=s.size();\n        if(n==k)return 0;\n        dp.resize(n,vector<int>(k+1,-1));\n        return solve(s,0,k);\n    }\n};\n```
['Dynamic Programming']