amazon oa
This commit is contained in:
18
392-240527-pass/main.py
Normal file
18
392-240527-pass/main.py
Normal file
@@ -0,0 +1,18 @@
|
||||
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
|
||||
print(idt_m, idt, cht)
|
||||
break
|
||||
if cnt == len(s): return True
|
||||
return False
|
||||
|
||||
sol = Solution()
|
||||
s = "axc"
|
||||
t = "ahbgdc"
|
||||
print(sol.isSubsequence(s,t))
|
Reference in New Issue
Block a user