1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/所有子字符串美丽值之和 [sum-of-beauty-of-all-substrings].html
2022-03-29 12:43:11 +08:00

33 lines
892 B
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>一个字符串的 <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>