3144. Minimum Substring Partition of Equal Character Frequency Medium

@problem@discussion
#Hash Table#String#Dynamic Programming#Counting



1/**
2 * [3144] Minimum Substring Partition of Equal Character Frequency
3 *
4 * Given a string s, you need to partition it into one or more balanced <span data-keyword="substring">substrings</span>. For example, if s == "ababcc" then ("abab", "c", "c"), ("ab", "abc", "c"), and ("ababcc") are all valid partitions, but ("a", "bab", "cc"), ("aba", "bc", "c"), and ("ab", "abcc") are not. The unbalanced substrings are bolded.
5 * Return the minimum number of substrings that you can partition s into.
6 * Note: A balanced string is a string where each character in the string occurs the same number of times.
7 *  
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">s = "fabccddg"</span>
11 * Output: <span class="example-io">3</span>
12 * Explanation:
13 * We can partition the string s into 3 substrings in one of the following ways: ("fab, "ccdd", "g"), or ("fabc", "cd", "dg").
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">s = "abababaccddb"</span>
18 * Output: <span class="example-io">2</span>
19 * Explanation:
20 * We can partition the string s into 2 substrings like so: ("abab", "abaccddb").
21 * </div>
22 *  
23 * Constraints:
24 * 
25 * 	1 <= s.length <= 1000
26 * 	s consists only of English lowercase letters.
27 * 
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/minimum-substring-partition-of-equal-character-frequency/
32// discuss: https://leetcode.com/problems/minimum-substring-partition-of-equal-character-frequency/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37    pub fn minimum_substrings_in_partition(s: String) -> i32 {
38        0
39    }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46    use super::*;
47
48    #[test]
49    fn test_3144() {
50    }
51}
52


Back
© 2025 bowen.ge All Rights Reserved.