Solution 1 - Two Pointer
Scan t and advance a pointer in s when characters match.
""" 0392.1 - Is Subsequence - Solution 1 - Two Pointer """
class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
i = 0
for ch in t:
if i < len(s) and s[i] == ch:
i += 1
return i == len(s)
if __name__ == "__main__":
print(Solution().isSubsequence("abc", "ahbgdc")) # True