Search⌘ K
AI Features

Solution: Distinct Subsequences

Solution: Distinct Subsequences asks you to count how many ways a target string can be matched exactly as a subsequence of a source string, deleting characters without changing the remaining order.

Statement

Given two strings, s and t, determine how many distinct subsequences of s match t exactly.

Note: A subsequence is formed by deleting zero or more characters from s without changing the relative order of the remaining characters.

You may assume the result will always fit within a 3232-bit signed integer.

Constraints:

  • 1≤1 \leq s.length, t.length ≤1000\leq 1000 ...