Skip to content

Practice Minimum Substring Partition of Equal Character Frequency

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

Medium#3144
LeetCode Problem

Minimum Substring Partition of Equal Character Frequency

Problem Statement

Given a string s, you need to partition it into one or more balanced substrings. 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. Return the minimum number of substrings that you can partition s into. Note: A balanced string is a string where each character in the string occurs the same number of times.

Source: Minimum Substring Partition of Equal Character Frequency on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "fabccddg"
Output
3

# Example 2

Input
s = "abababaccddb"
Output
2

Constraints

1 <= s.length <= 1000
s consists only of English lowercase letters.

Related LeetCode Problems

Practice more problems similar to Minimum Substring Partition of Equal Character Frequency.

Review your practice with PhantomCodeAI

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