MCPcopy Create free account
hub / github.com/Jonathan-Uy/CSES-Solutions / main

Function main

String Algorithms/Distinct Subsequences.cpp:12–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10char S[maxN];
11
12int main(){
13 scanf(" %s", S);
14 N = (int) strlen(S);
15 for(int i = 0; i < N; i++){
16 int c = (int) (S[i] - 'a');
17 dp[c]++;
18 for(int j = 0; j < 26; j++)
19 if(j != c)
20 dp[c] = (dp[c] + dp[j]) % MOD;
21 }
22
23 for(int i = 0; i < 26; i++)
24 tot = (tot + dp[i]) % MOD;
25 printf("%lld\n", tot);
26}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected