Good Subsequences

Asked at Nutanix · Coding Questions · Difficulty: Medium · Last asked Jul 15, 2026

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).

Loading the problem…