javascript dp solution beats 93.75%
\n/**\n * @param {string} s\n * @param {number} k\n * @return {number}\n */\nvar palindromePartition = function(s, k) {\n    const n = s.length;\n    const dp =
```\n/**\n * @param {string} s\n * @param {number} k\n * @return {number}\n */\nvar palindromePartition = function(s, k) {\n    const n = s.length;\n    const dp = Array.from({length: n}, () => Array(k+1).fill(100));\n    const cost = Array.from({length: n}, () => Array(n).fill(0));\n    \n    for (let len = 1; len < n; len++) {\n        for (let i = 0; i < n - len; i++) {\n            const j = i + len;\n            cost[i][j] = cost[i+1][j-1] + (s[i] == s[j] ? 0 : 1);\n        }\n    }\n    \n    for (let i = 0; i < n; i++) {\n        dp[i][1] = cost[0][i];\n        for (let kk = 2; kk <= k; kk++) {\n            for (let j = 0; j < i; j++) {\n                dp[i][kk] = Math.min(dp[i][kk], dp[j][kk-1] + cost[j+1][i]);\n            }\n        }\n    }\n   \n    return dp[n-1][k];\n};\n```
[]