


For the given string “deed” :
The possible subsequences are {“”}, {“d”}, {“e”}, {“de”}, {“e”}, {“de”}, {“ee”}, {“dee”}, {“d”}, {“dd”}, {“ed”}, {“ded”}, {“ed”}, {“ded”}, {“eed”} and {“deed”}.
As, {“d”}, {“e”}, {“de”}, {“ed”} and {“ded”} are repeated.
The distinct subsequences are {“”}, {“d”}, {“e”}, {“de”}, {“ee”}, {“dee”}, {“dd”}, {“ed”}, {“ded”}, {“eed”} and {“deed”}
Thus, the output will be 11.
As the answer can be large, return your answer modulo 10^9 + 7.
The first line contains an integer 'T' which denotes the number of test cases or queries to be run. Then, the T test cases follow.
The first and only line of each test case or query contains the string 'S'.
For each test case, print a single line containing the count of distinct subsequences modulo 10^9+7.
The output of each test case will be printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10 ^ 4
where 'T' is the number of test cases and 'N' is the length of the given string 'S'.
Time limit: 1 sec.
void helper(STR, set, ID, CUR) :
int distinctSubsequences(S) :
For example, let’s take the string ”abbcb”
For example, let’s take the string “ada”
Note: We have excluded empty string here.