[Solved] How to judge if a string contains a given substring (have gap)


If what you want to do is to check whether b is a subsequence of a, you can write:

def contains(a, b):
    n, m = len(a), len(b)
    j = 0
    for i in range(n):
        if j < m and a[i] == b[j]:
            j += 1
    return j == m

1

solved How to judge if a string contains a given substring (have gap)