mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
Update 0392.判断子序列.md
This commit is contained in:
@ -144,7 +144,20 @@ Java:
|
|||||||
|
|
||||||
|
|
||||||
Python:
|
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:
|
Go:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user