We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 63b3ede + ae8a0f2 commit e70378fCopy full SHA for e70378f
problems/0115.不同的子序列.md
@@ -222,7 +222,28 @@ class SolutionDP2:
222
223
Go:
224
225
+Javascript:
226
+```javascript
227
+const numDistinct = (s, t) => {
228
+ let dp = Array.from(Array(s.length + 1), () => Array(t.length +1).fill(0));
229
230
+ for(let i = 0; i <=s.length; i++) {
231
+ dp[i][0] = 1;
232
+ }
233
+
234
+ for(let i = 1; i <= s.length; i++) {
235
+ for(let j = 1; j<= t.length; j++) {
236
+ if(s[i-1] === t[j-1]) {
237
+ dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
238
+ } else {
239
+ dp[i][j] = dp[i-1][j]
240
241
242
243
244
+ return dp[s.length][t.length];
245
+};
246
+```
247
248
249
-----------------------
0 commit comments