Straightforward Python DP Solution
Time complexity: O(KN^3)\nSpace complexity: O(KN)\n\nnot optimized, but should be super straightforward. Feel free to leave optimzied version in comments\n\n\nc
Time complexity: O(KN^3)\nSpace complexity: O(KN)\n\nnot optimized, but should be super straightforward. Feel free to leave optimzied version in comments\n\n```\nclass Solution(object):\n    def palindromePartition(self, s, k):\n        """\n        :type s: str\n        :type k: int\n        :rtype: int\n        """\n        if not s:\n            return 0\n\n        if k > len(s):\n            return 0\n\n        dp = [[float(\'inf\')] * (k + 1) for _ in range(len(s) + 1)]\n        dp[0][0] = 0\n        for i in range(len(dp)):\n            dp[i][1] = self.min_op_palindrome(s[:i])\n\n        for i in range(1, len(dp)):\n            for j in range(2, len(dp[0])):\n                for m in range(i):\n                    dp[i][j] = min(dp[m][j - 1] + self.min_op_palindrome(s[m:i]), dp[i][j])\n        return dp[-1][k]\n\n    def min_op_palindrome(self, s):\n        if not s:\n            return 0\n\n        result = 0\n        i, j = 0, len(s) - 1\n        while i < j:\n            if s[i] != s[j]:\n                result += 1\n            i += 1\n            j -= 1\n        return result\n```
[]