1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/分割字符频率相等的最少子字符串 [minimum-substring-partition-of-equal-character-frequency].html
2024-05-16 15:32:41 +08:00

41 lines
1.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个字符串&nbsp;<code>s</code>&nbsp;,你需要将它分割成一个或者更多的&nbsp;<strong>平衡</strong>&nbsp;子字符串。比方说,<code>s == "ababcc"</code>&nbsp;那么&nbsp;<code>("abab", "c", "c")</code>&nbsp;<code>("ab", "abc", "c")</code>&nbsp;&nbsp;<code>("ababcc")</code>&nbsp;都是合法分割,但是&nbsp;<code>("a", <strong>"bab"</strong>, "cc")</code>&nbsp;<code>(<strong>"aba"</strong>, "bc", "c")</code>&nbsp;&nbsp;<code>("ab", <strong>"abcc"</strong>)</code>&nbsp;不是,不平衡的子字符串用粗体表示。</p>
<p>请你返回 <code>s</code>&nbsp;<strong>最少</strong> 能分割成多少个平衡子字符串。</p>
<p><b>注意:</b>一个 <strong>平衡</strong>&nbsp;字符串指的是字符串中所有字符出现的次数都相同。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>s = "fabccddg"</span></p>
<p><span class="example-io"><b>输出:</b>3</span></p>
<p><strong>解释:</strong></p>
<p>我们可以将 <code>s</code>&nbsp;分割成 3 个子字符串:<code>("fab, "ccdd", "g")</code>&nbsp;或者&nbsp;<code>("fabc", "cd", "dg")</code>&nbsp;</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>s = "abababaccddb"</span></p>
<p><span class="example-io"><b>输出:</b>2</span></p>
<p><strong>解释:</strong></p>
<p>我们可以将&nbsp;<code>s</code>&nbsp;分割成 2 个子字符串:<code>("abab", "abaccddb")</code>&nbsp;</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 1000</code></li>
<li><code>s</code>&nbsp;只包含小写英文字母。</li>
</ul>