algorythms
Dynamic Programming
LC #115Hard

Distinct Subsequences

Dynamic Programming
AmazonGoogleBloomberg

Problem

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

Inputs = "rabbbit", t = "rabbit"
Output3
Why

Three ways to pick "rabbit" from "rabbbit" (choose 2 of 3 b's)

Hints — reveal one at a time