执行用时 :1780 ms, 在所有 python3 提交中击败了12.50%的用户
内存消耗 :15 MB, 在所有 python3 提交中击败了32.00%的用户
class Solution: def numMatchingSubseq(self, S: str, words: List[str]) -> int: m=0 for i in range(len(words)): j=0 t=S while j<len(words[i]): if words[i][j] in t: d=t.index(words[i][j]) t=t[d+1:] j+=1 else: break if j==len(words[i]): m+=1 return m
耗时太多,如何优化???
有人说用双指针,我还没试。
——2019.10.16