2022-02-19 08:51:28 +00:00
|
|
|
class Solution:
|
|
|
|
def isSubsequence(self, s: str, t: str) -> bool:
|
2022-02-19 14:28:35 +00:00
|
|
|
slen, tlen, si, ti = len(s), len(t), 0, 0
|
2022-02-19 08:51:28 +00:00
|
|
|
|
|
|
|
# If s is longer than t, it's obviously not
|
|
|
|
# going to be a subsequence
|
|
|
|
if slen > tlen:
|
|
|
|
return False
|
|
|
|
|
|
|
|
while ti < tlen and si < slen:
|
2022-02-19 14:28:35 +00:00
|
|
|
if s[si] == t[ti]:
|
|
|
|
si += 1
|
2022-02-19 08:51:28 +00:00
|
|
|
|
2022-02-19 14:28:35 +00:00
|
|
|
ti += 1
|
2022-02-19 08:51:28 +00:00
|
|
|
|
2022-02-19 14:28:35 +00:00
|
|
|
return si == slen
|