Advertisement
smj007

Is subsequence

Apr 19th, 2025
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. class Solution:
  2.     def isSubsequence(self, s: str, t: str) -> bool:
  3.  
  4.         i = 0
  5.         j = 0
  6.  
  7.         while (i < len(s) and j < len(t)):
  8.             if s[i] == t[j]:
  9.                 i += 1
  10.             j += 1
  11.  
  12.         return i == len(s)
  13.  
  14.         # if j == len(t) and not i == len(s):
  15.         #     return False
  16.         # elif i == len(s) and not j == len(t):
  17.         #     return True
  18.         # elif i == len(s) and j == len(t):
  19.         #     return True
  20.  
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement