Good Subsequences
A subsequence of a given string is generated by deleting zero or more characters from a string, then concatenating the remaining characters. A good subsequence is one where the frequency of each character is the same. Given a string that consists of n Latin letters, determine how many good subsequences it contains. Since the answer can be quite large, compute its modulo (10^9 + 7).
Note: An empty subsequence is not a good subsequence.
Complete the function countGoodSubsequences in the editor below.
countGoodSubsequences has the following parameter(s):
- string word: a string that consists of only lowercase Latin letters
Returns
int: the number of good subsequences modulo (10^9 + 7)
1Example 1
2Example 2
Constraints
Limits and guarantees your solution can rely on.
- 1 ≤ length of word ≤ 10^5
- word[i] is in the range [a-z]