Skip to content

Latest commit

 

History

History
133 lines (53 loc) · 1.86 KB

File metadata and controls

133 lines (53 loc) · 1.86 KB

中文文档

Description

Given a string S, count the number of distinct, non-empty subsequences of S .

Since the result may be large, return the answer modulo 10^9 + 7.

 

Example 1:

Input: "abc"

Output: 7

Explanation: The 7 distinct subsequences are "a", "b", "c", "ab", "ac", "bc", and "abc".

Example 2:

Input: "aba"

Output: 6

Explanation: The 6 distinct subsequences are "a", "b", "ab", "ba", "aa" and "aba".

Example 3:

Input: "aaa"

Output: 3

Explanation: The 3 distinct subsequences are "a", "aa" and "aaa".

 

 

Note:

    <li><code>S</code> contains only lowercase letters.</li>
    
    <li><code>1 &lt;= S.length &lt;= 2000</code></li>
    

 

 

Solutions

Python3

Java

...