DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
hard
DP

Distinct Subsequences

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Distinct Subsequences** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** 2D DP count without deleting from t **Edge Cases to Consider:** - (1) t empty (1 way) - (2) s shorter than t - (3) Repeated characters

Examples

Example 1
Input: "rabbbit", "rabbit"
Output: 3
Explanation: 3 ways to choose b's
Example 2
Input: "babgbag", "bag"
Output: 5
Example 3
Input: "a", "a"
Output: 1

Constraints

  • ▪Input arguments are within valid ranges
  • ▪Optimize for execution speed
  • ▪Handle null/empty inputs gracefully

Watch Out For Edge Cases

  • ▪t empty (1 way)
  • ▪s shorter than t
  • ▪Repeated characters
Frequently Asked At
GoogleAmazonMicrosoftAdobe