C++  Top Down DP
\nint makePalindrome(int i,int j,string s)\n{\n\tint len=j-i+1;\n\tint ret=0;\n\tfor(int k=0;k<len/2;++k)\n\t\tif(s[i+k]!=s[j-k])\n\t\t\t++ret;\n\treturn ret;\n
```\nint makePalindrome(int i,int j,string s)\n{\n\tint len=j-i+1;\n\tint ret=0;\n\tfor(int k=0;k<len/2;++k)\n\t\tif(s[i+k]!=s[j-k])\n\t\t\t++ret;\n\treturn ret;\n}\nvector<vector<int>> memo;\nint dp(int i,int k,string& s,vector<vector<int>>& count)\n{\n\tif(k==0&&i==s.length())\n\t\treturn 0;\n\telse if(k==0||i>=s.length())\n\t\treturn 101;\n\telse if(memo[i][k]!=-1)\n\t\treturn memo[i][k];\n\telse\n\t{\n\t\tint q=101;\n\t\tfor(int j=i;j<s.length();++j)\n\t\t\tq=min(q,count[i][j]+dp(j+1,k-1,s,count));\n\t\treturn memo[i][k]=q;\n\t} \n}\nint palindromePartition(string s, int k) \n{\n\tint n=s.length();\n\tvector<vector<int>> count(n,vector<int>(n,0));\n\tfor(int i=0;i<n;++i)\n\t\tfor(int j=i+1;j<n;++j)\n\t\t\tcount[i][j]=makePalindrome(i,j,s);\n\tmemo.resize(n,vector<int>(k+1,-1));\n\treturn dp(0,k,s,count);\n}\n```
['Dynamic Programming', 'Memoization', 'C++']