Easy to understand Soln - Memoization
Complexity\n- Time complexity: O(k*n^2)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n^2)\n Add your space complexity here, e.g. O(n) \n
# Complexity\n- Time complexity: $$O(k*n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n^2)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```javascript []\n/**\n * @param {string} s\n * @param {number} k\n * @return {number}\n */\nvar palindromePartition = function(s, k) {\n  // I need to check whether a given string is palindrome or not\n  // If not a palindrome, what will be the number of operations reqd to make it palindromic\n  // I can store how many operations are reqd to make a subString palindromic\n  // Then I need to recursively look for all combinations and return the min ans\n  const n = s.length;\n  const pOperations = Array(n).fill(0).map(() => Array(n).fill(Infinity));\n  for(let len = 1; len<=n; len++) {\n    for(let i=0; i<=n-len; i++) {\n      let j = i+len-1;\n      let operations = s[i] === s[j] ? 0 : 1;\n      if(len > 2) operations += pOperations[i+1][j-1]; \n      pOperations[i][j] = operations;\n    }\n  }\n  const dp = new Map();\n  return helper(s, k, dp, pOperations, 0);\n};\n\nfunction helper(str, k, dp, pOperations, start) {\n  if(k === 1) return pOperations[start][str.length-1];\n  if(dp.has(key(k, start))) return dp.get(key(k, start));\n  let minOperations = Number.MAX_VALUE;\n  for(let i=start; i<=str.length-k; i++) {\n    minOperations = Math.min(pOperations[start][i] + helper(str, k-1, dp, pOperations, i+1), minOperations);\n  }\n  dp.set(key(k, start), minOperations);\n  return minOperations;\n}\n\nfunction key(a, b) {\n  return a+"_"+b;\n}\n```
['Dynamic Programming', 'JavaScript']