C++ solution , with Diagram
\n\nclass Solution {\npublic:\n    \n    vector<vector<int>>dp_change ;\n    vector<vector<int>>dp_partion ;\n    \n    int min_change( string& s, int start , i
![image](https://assets.leetcode.com/users/images/053ccb3f-af60-4c77-965b-d723e4a25eed_1633326078.61856.png)\n```\nclass Solution {\npublic:\n    \n    vector<vector<int>>dp_change ;\n    vector<vector<int>>dp_partion ;\n    \n    int min_change( string& s, int start , int end)\n    {\n        if( dp_change[start][end] != -1) return dp_change[start][end] ;\n       \n        int not_same = 0 ;\n        int i= start, j = end ;\n       \n        while( i< j)\n        {\n            if( s[i++] != s[j--] ) not_same++ ;\n        }\n        \n        return dp_change[start][end] = not_same ;\n    }\n    \n    \n    int partion_fxn( string& s, int start , int rem_partion)\n    {\n          if( dp_partion[start][rem_partion] != -1) return dp_partion[start][rem_partion] ;\n        \n        if( start == s.size() ) return 1e9 ;\n        \n        if( rem_partion ==0 ) return min_change( s, start, s.size()-1 ) ;\n        \n        int ans = 1e9 ;\n        \n        for( int i = start ; i<s.size() ; i++)\n        {\n            int no_of_change = min_change( s, start, i) ; \n            \n            ans = min( ans , no_of_change + partion_fxn( s, i+ 1, rem_partion-1 ) ) ;\n        }\n        \n        return dp_partion[start][rem_partion] = ans ;\n    }\n    \n    \n    int palindromePartition(string s, int k)\n    {\n        dp_change.resize( s.size()+ 1, vector<int>(s.size()+ 1, -1) ); \n        dp_partion.resize( s.size()+ 1, vector<int>(k , -1) ); \n        \n        \n        return partion_fxn( s, 0 , k-1 ) ;\n    }\n};\n```
[]