392. 判断子序列




class Solution(object):
    def isSubsequence(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: bool
        """
        if len(s) > len(t):
            return False
        elif len(s) == len(t):
            if s != t:
                return False
        for ch in s:
            if ch not in t:
                return False
            if ch in t:
                t = t[t.index(ch)+1:]
        return True
posted @ 2020-06-08 13:49  人间烟火地三鲜  阅读(137)  评论(0)    收藏  举报