Minimum Substring Partition of Equal Character Frequency

Given a string s, partition it into one or more balanced substrings.

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.

Example 1
Inputs = "fabccddg"
Output3
We can partition s into 3 balanced substrings, such as ("fab", "ccdd", "g") or ("fabc", "cd", "dg").
Example 2
Inputs = "abababaccddb"
Output2
We can partition s into 2 balanced substrings as ("abab", "abaccddb").

Constraints

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

Asked at 3 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate