Class Solution
java.lang.Object
g0901_1000.s0940_distinct_subsequences_ii.Solution
940 - Distinct Subsequences II.<p>Hard</p>
<p>Given a string s, return <em>the number of <strong>distinct non-empty subsequences</strong> of</em> <code>s</code>. Since the answer may be very large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>
<p>A <strong>subsequence</strong> of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., <code>"ace"</code> is a subsequence of <code>"abcde"</code> while <code>"aec"</code> is not.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “abc”</p>
<p><strong>Output:</strong> 7</p>
<p><strong>Explanation:</strong> The 7 distinct subsequences are “a”, “b”, “c”, “ab”, “ac”, “bc”, and “abc”.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “aba”</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Explanation:</strong> The 6 distinct subsequences are “a”, “b”, “ab”, “aa”, “ba”, and “aba”.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> s = “aaa”</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> The 3 distinct subsequences are “a”, “aa” and “aaa”.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= s.length <= 2000</code></li>
<li><code>s</code> consists of lowercase English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
distinctSubseqII
-