Advertisement
smj007

Untitled

Sep 16th, 2023
974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. class Solution:
  2.     def isSubsequence(self, s: str, t: str) -> bool:
  3.        
  4.         left, right = 0, 0
  5.  
  6.         while(left < len(s) and right <len(t)):
  7.             if s[left] == t[right]:
  8.                 left += 1
  9.                 right += 1
  10.             elif s[left] != t[right]:
  11.                 right += 1
  12.  
  13.         if left == len(s):
  14.             return True
  15.  
  16.         return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement