Skip to content

Latest commit

 

History

History
87 lines (44 loc) · 1.7 KB

File metadata and controls

87 lines (44 loc) · 1.7 KB

中文文档

Description

You are given a string s containing lowercase letters and an integer k. You need to :

    <li>First, change some characters of <code>s</code>&nbsp;to other lowercase English letters.</li>
    
    <li>Then divide <code>s</code>&nbsp;into <code>k</code> non-empty disjoint substrings such that each substring is palindrome.</li>
    

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:

    <li><code>1 &lt;= k &lt;= s.length &lt;= 100</code>.</li>
    
    <li><code>s</code>&nbsp;only contains lowercase English letters.</li>
    

Solutions

Python3

Java

...