changes to store the cost of converting substrings into palindromes.changes array by comparing characters at the two ends of each substring and moving inwards.dp with dimensions k by n and set all values to INT_MAX.dp[0][r] for all r to changes[0][r] as the base case.kk from 1 to k-1.kk, iterate over all possible right ends r of the substring.r, find the minimum cost by checking all possible left ends l of the last palindromic substring.dp[kk][r] with the minimum cost found.dp[k-1][n-1] as the final answer.