Given two strings s and t, return the number of distinct subsequences of s that equal t. Pattern focus: Distinct subsequences. This is the canonical count-the-ways DP problem on two strings.
s = source string, t = target string
number of distinct subsequences of s equal to t
Example 1:
Input:
s = "rabbbit" t = "rabbit"
Output:
3
Explanation:
There are three ways to delete one of the b characters.
Example 2:
Input:
s = "babgbag" t = "bag"
Output:
5
Explanation:
This is the classic example for counting subsequences.