leetcode——392. 判断子序列

简单题,一次完成。

class Solution:
    def isSubsequence(self, s: str, t: str) -> bool:
        if len(t)<len(s):
            return False
        i=0
        while i<len(s):
            if s[i] in t:
                d=t.index(s[i])
                t=t[d+1:]
                i+=1
            else:
                return False
        return True
执行用时 :52 ms, 在所有 python3 提交中击败了93.21%的用户
内存消耗 :18.1 MB, 在所有 python3 提交中击败了5.26%的用户
 
                                                          ——2019.10.16

猜你喜欢

转载自www.cnblogs.com/taoyuxin/p/11687067.html