Geeksforgeeks

Error

Given two strings **S **and** T** of length **n** and **m** respectively. find count of distinct occurrences of T in S as a sub-sequence.

**Example 1:**

**Input:**
S = "banana" , T = "ban"
**Output:** 3
**Explanation**: There are 3 sub-sequences:
[ban], [ba n], [b an].

â€‹**Example 2:**

**Input**:
S = "geeksforgeeks" , T = "ge"
**Output:** 6
**Explanation**: There are 6 sub-sequences:
[ge], [ ge], [g e], [g e] [g e] and [ g e].

**Your Task:**

You don't need to read input or print anything.Your task is to complete the function **subsequenceCount()** which takes two strings as argument S and T and returns the count of the sub-sequences modulo 10^{9} + 7.

**Expected Time Complexity:** O(n*m).

**Expected Auxiliary Space:** O(n*m).

**Constraints:**

1 ≤ length of(T) ≤ 100

1 ≤ length of(S) ≤ 8000

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Distinct occurrences

...