Typescript-Algorithms
    Preparing search index...

    Variable is_subsequenceConst

    is_subsequence: (s: string, t: string) => boolean = isSubsequence

    判断子序列,给出了子序列定义说明相对位置固定。那只要查找短串的字母是否在长串中依次出现就好了。 设计两个指针,一个指针p1指向短串,一个指针p2指向长串。 让p2一直往右边跑,如果p1每指向的字母在p2跑动过程中出现了,那么p1往前跑动一步,直到p2跑动完成,如果p1还没跑动到最右边。说明没子序列。

    Type declaration

      • (s: string, t: string): boolean
      • Parameters

        • s: string
        • t: string

        Returns boolean