Skip to content

Practice Palindrome Partitioning III

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#1278
LeetCode Problem

Palindrome Partitioning III

Problem Statement

Change as few characters of the lowercase string s as possible, replacing them with lowercase English letters, so that the result can be split into exactly k nonempty consecutive palindromic substrings. The substrings must cover the whole string without overlap. Return the minimum number of changed characters.

Source: Palindrome Partitioning III on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

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

# Example 3

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

Constraints

1 <= k <= s.length <= 100.
s only contains lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Palindrome Partitioning III.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.