leetcode/392-240527-pass/main.py
Hanzhang ma 3006568678 a
2024-06-02 21:36:19 +02:00

17 lines
474 B
Python

class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
cnt = 0
idt_m = 0
for idx, chs in enumerate(s):
for idt, cht in enumerate(t[idt_m:]):
if cht == chs:
idt_m = idt + idt_m + 1
cnt += 1
break
if cnt == len(s): return True
return False
sol = Solution()
s = "axc"
t = "ahbgdc"
print(sol.isSubsequence(s,t))