Class Solution
java.lang.Object
g1701_1800.s1781_sum_of_beauty_of_all_substrings.Solution
1781 - Sum of Beauty of All Substrings.<p>Medium</p>
<p>The <strong>beauty</strong> of a string is the difference in frequencies between the most frequent and least frequent characters.</p>
<ul>
<li>For example, the beauty of <code>"abaacc"</code> is <code>3 - 1 = 2</code>.</li>
</ul>
<p>Given a string <code>s</code>, return <em>the sum of <strong>beauty</strong> of all of its substrings.</em></p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “aabcb”</p>
<p><strong>Output:</strong> 5</p>
<p><strong>Explanation:</strong> The substrings with non-zero beauty are [“aab”,“aabc”,“aabcb”,“abcb”,“bcb”], each with beauty equal to 1.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “aabcbaa”</p>
<p><strong>Output:</strong> 17</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= s.length <= 500</code></li>
<li><code>s</code> consists of only lowercase English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
beautySum
-