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.
Examples
Example 1
Input: s = "abc", k = 2
Output: 1
Explanation: 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
Explanation: 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
1 <= k <= s.length <= 100.
s only contains lowercase English letters.
1278. Palindrome Partitioning III
Hard
50 Points
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.
Examples
Example 1
Input: s = "abc", k = 2
Output: 1
Explanation: 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
Explanation: 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
1 <= k <= s.length <= 100.
s only contains lowercase English letters.
Palindrome Partitioning III - Practice Coding | SlaveCode