Good Subsequences
Practice
2.9 (30 votes)
Algorithms
Easy
String manipulation
Problem
76% Success 6290 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

You are given a string \(S\) consisting of lowercase alphabets. A good subsequence of this string is a subsequence which contains distinct characters only. 
Determine the number of good subsequences of the maximum possible length modulo \(10^9 + 7\).

In other words, determine the length \(X\) of the longest good subsequence and the number of good subsequences of length \(X\) modulo \(10^9 + 7\).

Input format

  • First line: An integer \(T\) denoting the number of test cases
  • Each of the next \(T\) lines: String \(S\)

Output format

For each test case, print the number of good subsequences of the maximum length modulo \(10^9 + 7\).
Answer for each test case should come in a new line.

Input Constraints

\(1 \le T \le 10\)

\(1 \le |S| \le 10^5\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
36 votes
Tags:
Ad-HocApprovedData StructuresEasyImplementationOpen
Points:20
40 votes
Tags:
AlgorithmsApprovedEasyOpen
Points:20
84 votes
Tags:
ApprovedEasyOpen