_3144

package
v0.0.0-...-5ea41ec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 1 Imported by: 0

README

分割字符频率相等的最少子字符串

给你一个字符串 s ,你需要将它分割成一个或者更多的 平衡 子字符串。比方说,s == "ababcc" 那么 ("abab", "c", "c") ,("ab", "abc", "c") 和 ("ababcc") 都是合法分割,但是 ("a", "bab", "cc") ,("aba", "bc", "c") 和 ("ab", "abcc") 不是,不平衡的子字符串用粗体表示。

请你返回 s最少 能分割成多少个平衡子字符串。

**注意:**一个 平衡 字符串指的是字符串中所有字符出现的次数都相同。

示例 1:

**输入:**s = "fabccddg"

**输出:**3

解释:

我们可以将 s 分割成 3 个子字符串:("fab, "ccdd", "g") 或者 ("fabc", "cd", "dg") 。

示例 2:

**输入:**s = "abababaccddb"

**输出:**2

解释:

我们可以将 s 分割成 2 个子字符串:("abab", "abaccddb") 。

提示:

  • 1 <= s.length <= 1000
  • s 只包含小写英文字母。

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL