MCPcopy Create free account
hub / github.com/Ainevsia/Leetcode-Rust / numDistinct

Method numDistinct

115. Distinct Subsequences/Solution.cpp:16–26  ·  view source on GitHub ↗

string dp

Source from the content-addressed store, hash-verified

14public:
15 // string dp
16 int numDistinct(string s, string t) {
17 vector <vector<long long>> dp(t.size()+1, vector<long long>(s.size()+1, 0L));
18 for (auto &i : dp[0]) i = 1;
19 for (int i=1;i<=t.size();i++)
20 for (int j=1;j<=s.size();j++)
21 if (t[i-1] == s[j-1])
22 dp[i][j] = dp[i-1][j-1] + dp [i][j-1];
23 else
24 dp[i][j] = dp[i][j-1];
25 return dp[t.size()][s.size()];
26 }
27};
28
29int main() {

Callers 1

mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected