C++ Iterative DP solution
First we shall calculate the minimum characters to be changed to make any subarray l to r a palindrome. Let us consider this value as the cost to make subarray 
First we shall calculate the minimum characters to be changed to make any subarray l to r a palindrome. Let us consider this value as the cost to make subarray l to r a palindrome. \nWe can manually calculate for subarrays of length 1 and 2.\nFor subarray of length>=3\n\n```\ncost[l][r]=cost[l+1][r-1]+(s[l]!=s[r]);\n```\n\nOnce we\'ve calculated the cost we define the state as follows-\n\n```\ndp[i][j] = minimum cost to partition substring 1 to i into j segments. \n```\nThe transition would be as follows-\n```\ndp[i][j]=min(dp[i-1][j-1]+cost[i][i], dp[i-2][j-1]+cost[i-1][i], dp[i-3][j-1]+cost[i-2][j-1]... dp[0][j-1]+cost[1][i])\n```\n\nThe entire code-\n```\nclass Solution {\npublic:\n    int palindromePartition(string s, int k) {\n        int n=s.size();\n        int cost[n+1][n+1];\n        for(int i=1;i<=n;i++)\n        {\n            cost[i][i]=0;\n            if(i>1)\n            {\n                cost[i-1][i]=(s[i-1]!=s[i-2]);\n            }\n        }\n        for(int i=3;i<=n;i++)\n        {\n            for(int j=1;i+j-1<=n;j++)\n            {\n                int l=j,r=i+j-1;\n                cost[l][r]=cost[l+1][r-1]+(s[l-1]!=s[r-1]);\n            }\n        }\n        int dp[n+1][k+1];\n        for(int i=0;i<=n;i++)\n        {\n            for(int j=0;j<=k;j++)\n            {\n                dp[i][j]=n+1;\n            }\n        }\n        dp[0][0]=0;\n        for(int i=1;i<=n;i++)\n        {\n            for(int j=1;j<=k;j++)\n            {\n                for(int l=0;l<i;l++)\n                {\n                    dp[i][j]=min(dp[i][j],dp[l][j-1]+cost[l+1][i]);\n                }\n            }\n        }\n        return dp[n][k];\n    }\n};\n```\n
['String', 'Dynamic Programming']