Dynamic Programming
LC #115Hard
Distinct Subsequences
Dynamic Programming
AmazonGoogleBloombergProblem
Count the number of distinct subsequences of string s that equal string t.
dynamic-programmingstring
Constraints
- ›1 ≤ s.length ≤ 1000
- ›1 ≤ t.length ≤ 1000
- ›Answer fits in 32-bit integer
Example
Input
s = "rabbbit", t = "rabbit"Output
3Why
Three ways to pick "rabbit" from "rabbbit" (choose 2 of 3 b's)