102. Distinct Subsequences

HardDynamic Programming

Given two strings s and t, return the number of distinct subsequences of s which equals t. The test cases are generated so that the answer fits on a 32-bit signed integer.

Examples

Input: rabbbit rabbit

Output: 3

Explanation: There are 3 distinct ways to pick 'rabbit' as a subsequence of 'rabbbit'.

Constraints

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

Run checks all cases above. Submit evaluates all test cases.