New Python Solution cutting main string

  • -1

    Basically we cut t each time going through one item from s to t[index+1:]. If it goes through all the cases and survive then it's true

    class Solution(object):
    def isSubsequence(self, s, t):
    :type s: str
    :type t: str
    :rtype: bool
    if not t and s:
    ----return False
    if not s :
    ----return True
    for item in s:
    ----if item not in t:
    --------return False
    ----i = t.index(item)
    ----t = t[i+1:]
    return True

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.