Hard
Distinct Subsequences
Hard
17 submissions
50 coins
+200 XP
Dynamic Programming
String
Problem Description
Return how many distinct ways `t` can be formed as a subsequence of `s` (choosing different index sets counts as different ways).
**Example 1:**
```
Input: s = "rabbbit", t = "rabbit"
Output: 3
```
**Example 2:**
```
Input: s = "babgbag", t = "bag"
Output: 5
```
**Example 3:**
```
Input: s = "abc", t = "d"
Output: 0
```
Constraints
- `1 <= s.length, t.length <= 1000`
- The answer fits in a 32-bit signed integer.
Need help?
Connect with expert programmers for real-time collaborative coding, video meetings, and whiteboard sessions via CodeConnect.
Video Call
Whiteboard
Live Coding
Screen Share