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-deletions-to-make-character-frequencies-unique].html
2022-03-29 12:43:11 +08:00

42 lines
1.5 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>如果字符串 <code>s</code><strong>不存在</strong> 两个不同字符 <strong>频次</strong> 相同的情况,就称 <code>s</code><strong>优质字符串</strong></p>
<p>给你一个字符串 <code>s</code>,返回使 <code>s</code> 成为 <strong>优质字符串</strong> 需要删除的 <strong>最小</strong> 字符数。</p>
<p>字符串中字符的 <strong>频次</strong> 是该字符在字符串中的出现次数。例如,在字符串 <code>"aab"</code> 中,<code>'a'</code> 的频次是 <code>2</code>,而 <code>'b'</code> 的频次是 <code>1</code></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>s = "aab"
<strong>输出:</strong>0
<strong>解释:</strong><code>s</code> 已经是优质字符串。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = "aaabbbcc"
<strong>输出:</strong>2
<strong>解释:</strong>可以删除两个 'b' , 得到优质字符串 "aaabcc" 。
另一种方式是删除一个 'b' 和一个 'c' ,得到优质字符串 "aaabbc" 。</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>s = "ceabaacb"
<strong>输出:</strong>2
<strong>解释:</strong>可以删除两个 'c' 得到优质字符串 "eabaab" 。
注意,只需要关注结果字符串中仍然存在的字符。(即,频次为 0 的字符会忽略不计。)
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= s.length <= 10<sup>5</sup></code></li>
<li><code>s</code> 仅含小写英文字母</li>
</ul>