392. Is Subsequence
Solution:
- using two pointers. loop through the target string
t, for each index, check if the remaining substring of target contains strings.
class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
l = 0
while l < len(t) - len(s) + 1:
r = l
i = 0
while r < len(t) and i < len(s):
if s[i] == t[r]:
i += 1
r += 1
if i == len(s):
return True
l += 1
return False