Skip to content

Commit

Permalink
Update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Haleshot committed Aug 16, 2024
1 parent 702492b commit eba02ca
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion Algomap/Is_Subsequence/Is_Subsequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,27 @@ def isSubsequence(self, s, t):
:type t: str
:rtype: bool
"""

# Step 1
if not s:
return True

i, j = 0, 0
while i < len(s) and j < len(t):
if s[i] == t[j]:
i += 1
j += 1

return i == len(s)

# # Step 2:
# if s == "": return True
# if len(s) > len(t): return False

# j = 0

# for i in range(len(t)):
# if s[j] == t[i]:
# if j == len(s) - 1:
# return True
# j += 1
# return False

0 comments on commit eba02ca

Please sign in to comment.