LeetCode 1781. Sum of Beauty of All Substrings
The beauty of a string is the difference in frequencies between the most frequent and least frequent characters.
For example, the beauty of
"abaacc"
is3 - 1 = 2
.
Given a string s
, return the sum of beauty of all of its substrings.
Example 1:
Example 2:
Constraints:
1 <= s.length <= 500
s
consists of only lowercase English letters.
Solution:
PreviousLeetCode 1780. Check if Number is a Sum of Powers of ThreeNextLeetCode 1782. Count Pairs Of Nodes
Last updated