


The first line of input contains an integer ‘T’ representing the number of test cases. Then the test cases follow.
The first line of each test case contains string S consisting of lowercase English letters.
The second line of each test case contains string T consisting of lowercase English letters.
For each test case, print a single integer denoting the count of distinct occurrences of T in S as a subsequence.
The output for each test case is in a separate line.
You do not need to print anything; it has already been taken care of.
1 <= T <= 10
1 <= N <= 100
Where ‘T’ is the number of test cases, and ‘N’ is the length of the strings.
Time Limit: 1sec
If we carefully analyze the given problem, we can see that it can be easily divided into sub-problems which can be solved using recursion. The idea is to process all characters of both strings one by one starting from either from left or right side. Let us traverse from the right corner, there are two possibilities for every pair of characters being traversed.
Base Cases:
Recursive Cases:
Dynamic Programming approach can be applied to solve this problem. The idea is to store the subproblems in a HashMap or an array and return the value when the function is called again.
Below is the algorithm: