Skip to content

Practice Distinct Subsequences

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#115
LeetCode Problem

Distinct Subsequences

Problem Statement

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.

Source: Distinct Subsequences on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "rabbbit", t = "rabbit"
Output
3

# Example 2

Input
s = "babgbag", t = "bag"
Output
5

Constraints

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

Related LeetCode Problems

Practice more problems similar to Distinct Subsequences.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.