Skip to content

Commit

Permalink
Update 0392.判断子序列.md
Browse files Browse the repository at this point in the history
  • Loading branch information
z80160280 authored Jun 9, 2021
1 parent a4b7399 commit a720426
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion problems/0392.判断子序列.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,20 @@ Java:
Python:
```python
class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
dp = [[0] * (len(t)+1) for _ in range(len(s)+1)]
for i in range(1, len(s)+1):
for j in range(1, len(t)+1):
if s[i-1] == t[j-1]:
dp[i][j] = dp[i-1][j-1] + 1
else:
dp[i][j] = dp[i][j-1]
if dp[-1][-1] == len(s):
return True
return False
```

Go:

Expand Down

0 comments on commit a720426

Please sign in to comment.