Concise DFS - Python
\nclass Solution:\n    def palindromePartition(self, s: str, k: int) -> int:\n        self.mem = {}\n        return self.dfs(s, k)\n\n    def dfs(self, s, k):\n
```\nclass Solution:\n    def palindromePartition(self, s: str, k: int) -> int:\n        self.mem = {}\n        return self.dfs(s, k)\n\n    def dfs(self, s, k):\n        if (s, k) in self.mem:\n            return self.mem[(s, k)]\n        if len(s) == k:\n            return 0\n        if k == 1:\n            res = sum([s[i] != s[-1-i] for i in range(len(s) // 2)])\n        else:\n            res = float("Inf")\n            for i in range(1, len(s) - k + 2):\n                res = min(self.dfs(s[:i], 1) + self.dfs(s[i:], k - 1), res)\n        self.mem[(s, k)] = res\n        return res\n```
[]