cheetcode

118. Distinct SubsequencesHard

Count how many subsequences of one string equal another string.

Given strings s and t, return the number of distinct subsequences of s that equal t.

Examples

Input: s = "rabbbit", t = "rabbit"
Output: 3
Input: s = "babgbag", t = "bag"
Output: 5

Constraints

  • 1 <= s.length, t.length <= 1000
  • s and t consist of English letters.