Tap here to switch tabs
Problem
Submissions

Problem: Sum of Beauty of All Substrings

med
30 min
Try to solve the Sum of Beauty of All Substrings problem.

Statement

The beauty of a string is defined as the difference between the maximum frequency and the minimum frequency of any character that appears in that string.

Given a string s, return the total sum of the beauty of all its substrings.

Constraints:

  • 1≤1 \leq s.length ≤500\leq 500

  • s consists of only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum of Beauty of All Substrings

med
30 min
Try to solve the Sum of Beauty of All Substrings problem.

Statement

The beauty of a string is defined as the difference between the maximum frequency and the minimum frequency of any character that appears in that string.

Given a string s, return the total sum of the beauty of all its substrings.

Constraints:

  • 1≤1 \leq s.length ≤500\leq 500

  • s consists of only lowercase English letters.