Company: Agoda_27july
Difficulty: medium
Good Subsequences Problem Description A subsequence is formed by deleting zero or more characters from a string and concatenating the remaining characters. A subsequence is considered "good" if the frequency of each character in the subsequence is the same. Given a string of n English letters, determine how many good subsequences it contains. Since the answer can be large, compute it modulo (10 9 +7). Note: An empty subsequence is not considered a good subsequence. Examples Example 1: Input: word = "abca" Output: 12 Explanation: From this string, we can form 15 non-empty subsequences. The only subsequences that are not good are: "aba" (character 'a' appears twice, 'b' appears once) "aca" (character 'a' appears twice, 'c' appears once) "abca" (character 'a' appears twice, 'b' and 'c' appear once each) The total number of good subsequences = 15 - 3 = 12, and the answer is 12 modulo (10 9 +7) = 12. Sample Case 0: Input: word = "abcd" Output: 15 Explanation: All of the non-empty subsequenc