Total Appeal of A String
The appeal of a string is the number of distinct characters found in the string.
- For example, the appeal of
"abbca"is3because it has3distinct characters:'a','b', and'c'.
Given a string s, return the total appeal of all of its substrings.
A substring is a contiguous sequence of characters within a string.
Example 1
Input
s = "abbca"Output
28The total appeal over all substrings of
"abbca" is 5 + 7 + 7 + 6 + 3 = 28.Example 2
Input
s = "code"Output
20The total appeal over all substrings of
"code" is 4 + 6 + 6 + 4 = 20.Constraints
- 1 <= s.length <= 10^5
- s consists of lowercase English letters.