Zepruv › Coding problems

Palindrome Partitioning III

Hard · String, Dynamic Programming

You are given a string s containing lowercase letters and an integer k. You need to :
Return the minimal number of characters that you need to change to divide the string.

Example 1

Input: s = "abc", k = 2
Output: 1

You can split the string into "ab" and "c", and change 1 character in "ab" to make it palindrome.

Example 2

Input: s = "aabbc", k = 3
Output: 0

You can split the string into "aa", "bb" and "c", all of them are palindrome.

Example 3

Input: s = "leetcode", k = 8
Output: 0

Constraints

Starter code (python)

class Solution(object):
    def palindromePartition(self, s, k):
        """
        :type s: str
        :type k: int
        :rtype: int
        """
        

Related problems

Previous: Number of Burgers with No Waste of Ingredients · Next: Find the Smallest Divisor Given a Threshold · All problems

Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.