1278. Palindrome Partitioning III Hard

@problem@discussion
#String#Dynamic Programming



1/**
2 * [1278] Palindrome Partitioning III
3 *
4 * You are given a string s containing lowercase letters and an integer k. You need to :
5 * 
6 * 	First, change some characters of s to other lowercase English letters.
7 * 	Then divide s into k non-empty disjoint substrings such that each substring is a palindrome.
8 * 
9 * Return the minimal number of characters that you need to change to divide the string.
10 *  
11 * Example 1:
12 * 
13 * Input: s = "abc", k = 2
14 * Output: 1
15 * Explanation: You can split the string into "ab" and "c", and change 1 character in "ab" to make it palindrome.
16 * 
17 * Example 2:
18 * 
19 * Input: s = "aabbc", k = 3
20 * Output: 0
21 * Explanation: You can split the string into "aa", "bb" and "c", all of them are palindrome.
22 * Example 3:
23 * 
24 * Input: s = "leetcode", k = 8
25 * Output: 0
26 * 
27 *  
28 * Constraints:
29 * 
30 * 	1 <= k <= s.length <= 100.
31 * 	s only contains lowercase English letters.
32 * 
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/palindrome-partitioning-iii/
37// discuss: https://leetcode.com/problems/palindrome-partitioning-iii/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42    pub fn palindrome_partition(s: String, k: i32) -> i32 {
43        0
44    }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn test_1278() {
55    }
56}
57


Back
© 2025 bowen.ge All Rights Reserved.