Available question text
Compute the sum, over all substrings of s (n ≤ 500), of the "beauty" defined as the difference between the most frequent and least frequent characters that appear in the substring. The key challenge is enumerating substrings while maintaining character counts to efficiently compute max/min nonzero frequencies (typical solutions use O(n^2 · 26) counting).
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1781. Sum of Beauty of All Substrings
Interview date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source