Skip to content

Commit 5dada70

Browse files
committed
Create P116. 判断子序列.md
1 parent d6d138b commit 5dada70

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

P116. 判断子序列.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
***给定字符串 s 和 t ,判断 s 是否为 t 的子序列。***
2+
3+
```
4+
输入:s = "abc", t = "ahbgdc"
5+
输出:true
6+
```
7+
8+
```
9+
class Solution:
10+
def isSubsequence(self, s: str, t: str) -> bool:
11+
m, n = len(s), len(t)
12+
i=j=0
13+
while i<m and j<n:
14+
if s[i]==t[j]:
15+
i+=1
16+
j+=1
17+
return i==m
18+
```

0 commit comments

Comments
 (0)