← ALL NOTES
String

115. Distinct Subsequences

2D DP over prefixes: dp[i][j] is the number of ways to form the first j characters of t using the first i of s. At each cell you have two independent options — skip s[i-1] (inherit dp[i-1][j]), and,…

Loading…