Trains the technique from
LeetCode 2262Total Appeal of A StringThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A reel of labels reads s, a string of lowercase letters. The variety of a contiguous stretch of the reel is how many distinct letters it holds.
Return the total variety over every non-empty contiguous stretch of the reel.
Example 1
Every one of the sixty-six stretches contributes its own count of distinct letters, and those counts add up to this total.
Example 2
The stretches are "a" with variety 1, "b" with variety 1, and "ab" with variety 2, giving 4.
Example 3
Each single label has variety 1 and the whole reel still has variety 1, since the repeat adds no new letter, giving 3.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def appeal_sum(s: str) -> int:public long appealSum(String s)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.