C++ Bottom Up DP
\nclass Solution {\npublic:\n    int palindromePartition(string s, int k) {\n     int n=s.length();\n    vector<vector<int>>p(n,vector<int>(n,n));\n    for(int 
```\nclass Solution {\npublic:\n    int palindromePartition(string s, int k) {\n     int n=s.length();\n    vector<vector<int>>p(n,vector<int>(n,n));\n    for(int i=0;i<n;i++)\n        p[i][i]=0;\n    for(int i=0;i<n-1;i++)\n    {\n    if(s[i]==s[i+1])p[i][i+1]=0;\n    else\n        p[i][i+1]=1;\n    }\n     for(int len=3;len<=n;len++)\n     {\n      for(int i=0;i<n-len+1;i++)\n      {\n       int j=i+len-1;\n        if(s[i]==s[j])p[i][j]=p[i+1][j-1];\n         else\n             p[i][j]=1+p[i+1][j-1];\n      }\n     }\n    vector<vector<int>>dp(n,vector<int>(k,1e5));\n    for(int i=0;i<n;i++)\n    {\n     for(int j=0;j<k;j++)\n     {\n    if(j==0){dp[i][j]=p[0][i];continue;}\n    for(int h=i-1;h>=0;h--)\n    {\n        dp[i][j]=min(dp[i][j],dp[h][j-1]+p[h+1][i]);    \n    }\n     }\n    }\n    return dp[n-1][k-1];\n    }\n};\n```
[]