Sale
Summer Offer: $190/yr $99/yr
00 : 00 : 00 : 00
Get this deal
Backend Engineer Senior programming

Given two strings s and t, return the number of distinct subsequences of s which equals t. A subsequence of a string is obtained by deleting some characters without changing the order of the remaining characters. Please implement the following function:


def numDistinct(s: str, t: str) -> int:

Constraints:


  • 0 <= s.length, t.length <= 1000

  • s and t consist of English letters.


Example 1:


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

Example 2:


Input: s = "abc", t = "abc"
Output: 1
Suggested Answer

Trusted by 100+ professionals preparing for interviews

Trusted by 100+ professionals 50+ Company Question Banks 5+ Supported Languages

Practice More Questions Like This

Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.

Get Started Free
Link copied to clipboard