Simple Python solution


  • 0
    class Solution(object):
        def isSubsequence(self, s, t):
            i = 0; j = 0; m = len(s); n = len(t)
            while i < m:
                if j >= n: return False
                if s[i] == t[j]: i += 1
                j += 1
            return True
    

Log in to reply
 

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