Dashboard
LC #115

Distinct Subsequences

Pattern · ?AmazonGoogleBloomberg

Problem

Count the number of distinct subsequences of string s that equal string t.

Constraints

  • 1 ≤ s.length ≤ 1000
  • 1 ≤ t.length ≤ 1000
  • Answer fits in 32-bit integer

Example

Input
s = "rabbbit", t = "rabbit"
Output
3
Why
Three ways to pick "rabbit" from "rabbbit" (choose 2 of 3 b's)

Spot the pattern

Which pattern cracks it?

Hints

One at a time
Solve on LeetCode ↗