


1. A subsequence is a sequence generated from a string after deleting some characters of string without changing the order of remaining string characters.
2. 'A' and 'B' will be non-empty strings.
The first line of the input contains an integer 'T' denoting the number of test cases.
The first line of each test case contains two space-separated integers 'N' and 'M', the length of string 'A' and 'B' respectively.
The second line of each test case contains a string 'A'.
The third line of each test case contains a string 'B'.
For each test case, return an integer denoting the number of distinct occurrences of 'B' in 'A' as a subsequence.
You don't need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 100
1 <= M, N <= 100
Time limit: 1 sec
We will start by generating all the possible subsequences of String ‘A’ using recursion. For every character there are two choices either to include it in the subsequence or not. Apply this for every character from start until we reach the end of the string. Push the subsequence into a data structure like a vector once the end of string is reached.
We will store all these subsequences in a data structure like a vector/list, also we’ll keep an integer ‘COUNT’ (which is initially equal to 0), which gives the count of the number of distinct occurrences of string ‘B’ in the string ‘A’ as a subsequence.
Traverse this data structure and check if the current element of the vector is equal to the String ‘B' or not. If it is equal to string ‘B’, increment the ‘COUNT’ by 1. Finally, return ‘COUNT’.
We will start by creating a recursive function such that it returns the count of distinct occurrences of string ‘B’ in ‘A’. We’ll create a 2 Dimensional ‘DP’ Array ‘DP[i][j]’, Where ‘M’ is the length of string ‘B’ and 'N' is the length of string ‘A’ and ‘DP[i][j]’ denotes the number of distinct occurrence of a substring of string ‘B(1..i)’ as a subsequence of the substring of string ‘A(1..j)’.
Base Cases:
Recursive Cases: