python (贪心算法)判断是否是子序列
描述:
给定字符串 s 和 t ,判断 s 是否为 t 的子序列。
整体思路:
循环s子序列,判断s中的所有字符都会按照顺序出现在t中
class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
index = 0
for value in s:
index = t.find(value, index)
if index == -1:
return False
index += 1
return True

浙公网安备 33010602011771号