Class Solution
java.lang.Object
g0101_0200.s0115_distinct_subsequences.Solution
115 - Distinct Subsequences.<p>Hard</p>
<p>Given two strings <code>s</code> and <code>t</code>, return <em>the number of distinct subsequences of <code>s</code> which equals <code>t</code></em>.</p>
<p>A string’s <strong>subsequence</strong> is a new string formed from the original string by deleting some (can be none) of the characters without disturbing the remaining characters’ relative positions. (i.e., <code>"ACE"</code> is a subsequence of <code>"ABCDE"</code> while <code>"AEC"</code> is not).</p>
<p>It is guaranteed the answer fits on a 32-bit signed integer.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “rabbbit”, t = “rabbit”</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> As shown below, there are 3 ways you can generate “rabbit” from S. <code>**rabb**b**it**</code> <code>**ra**b**bbit**</code> <code>**rab**b**bit**</code></p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “babgbag”, t = “bag”</p>
<p><strong>Output:</strong> 5</p>
<p><strong>Explanation:</strong> As shown below, there are 5 ways you can generate “bag” from S. <code>**ba**b**g**bag</code> <code>**ba**bgba**g**</code> <code>**b**abgb**ag**</code> <code>ba**b**gb**ag**</code> <code>babg**bag**</code></p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= s.length, t.length <= 1000</code></li>
<li><code>s</code> and <code>t</code> consist of English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
numDistinct
-