Class Solution
-
- All Implemented Interfaces:
public final class Solution1278 - Palindrome Partitioning III\.
Hard
You are given a string
scontaining lowercase letters and an integerk. You need to :First, change some characters of
sto other lowercase English letters.Then divide
sintoknon-empty disjoint substrings such that each substring is a palindrome.
Return the minimal number of characters that you need to change to divide the string.
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.sonly contains lowercase English letters.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegerpalindromePartition(String s, Integer k)-
-
Method Detail
-
palindromePartition
final Integer palindromePartition(String s, Integer k)
-
-
-
-