mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
33 lines
892 B
HTML
33 lines
892 B
HTML
<p>一个字符串的 <strong>美丽值</strong> 定义为:出现频率最高字符与出现频率最低字符的出现次数之差。</p>
|
||
|
||
<ul>
|
||
<li>比方说,<code>"abaacc"</code> 的美丽值为 <code>3 - 1 = 2</code> 。</li>
|
||
</ul>
|
||
|
||
<p>给你一个字符串 <code>s</code> ,请你返回它所有子字符串的 <strong>美丽值</strong> 之和。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<b>输入:</b>s = "aabcb"
|
||
<b>输出:</b>5
|
||
<strong>解释:</strong>美丽值不为零的字符串包括 ["aab","aabc","aabcb","abcb","bcb"] ,每一个字符串的美丽值都为 1 。</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<b>输入:</b>s = "aabcbaa"
|
||
<b>输出:</b>17
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= s.length <=<sup> </sup>500</code></li>
|
||
<li><code>s</code> 只包含小写英文字母。</li>
|
||
</ul>
|