6885.Distinct Subsequences

Time Limit: 1s Memory Limit: 512MB

You are given a string. You can remove any number of characters from it, but you cannot change the order of the remaining characters.

How many different strings can you generate?

Input Format(From the terminal/stdin)

The first input line contains a string of size $n$ . Each character is one of a–z.

  • $1 \le n \le 5 \cdot 10^5$

Output Format(To the terminal/stdout)

Print one integer: the number of strings modulo $10^9+7$ .

Sample Input

Copy
aybabtu
       \n

Sample Output

Copy
103
   \n
Source: CSES, String Algorithms, 1149

Submit

请先 登录

© 2025 FAQs