Count how many subsequences of s equal t.
DP on prefixes:
dp[j] = number of ways to form t[:j] from processed prefix of s.
For each char in s, update j backwards:
if s[i-1]==t[j-1], add ways for t[:j-1].
When chars match, you can either use this s char to match t[j-1] or skip it; backward iteration prevents double counting.
Count how many subsequences of s equal t.
DP on prefixes:
dp[j] = number of ways to form t[:j] from processed prefix of s.
For each char in s, update j backwards:
if s[i-1]==t[j-1], add ways for t[:j-1].
When chars match, you can either use this s char to match t[j-1] or skip it; backward iteration prevents double counting.