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.
1 parent 513ccbc commit 617499fCopy full SHA for 617499f
problems/0115.不同的子序列.md
@@ -221,6 +221,30 @@ class SolutionDP2:
221
```
222
223
Go:
224
+```go
225
+func numDistinct(s string, t string) int {
226
+ dp:= make([][]int,len(s)+1)
227
+ for i:=0;i<len(dp);i++{
228
+ dp[i] = make([]int,len(t)+1)
229
+ }
230
+ // 初始化
231
232
+ dp[i][0] = 1
233
234
+ // dp[0][j] 为 0,默认值,因此不需要初始化
235
+ for i:=1;i<len(dp);i++{
236
+ for j:=1;j<len(dp[i]);j++{
237
+ if s[i-1] == t[j-1]{
238
+ dp[i][j] = dp[i-1][j-1] + dp[i-1][j]
239
+ }else{
240
+ dp[i][j] = dp[i-1][j]
241
242
243
244
+ return dp[len(dp)-1][len(dp[0])-1]
245
+}
246
+```
247
+
248
249
Javascript:
250
```javascript
0 commit comments