1st.
class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
for S in range(s):
len(S)
for T in range(t):
len(T)
if S == T:
return True
else:
return False
2nd with chatGPT
def isSubsequence(s: str, t: str) -> bool:
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)
# Example usage:
s = "abc"
t = "ahbgdc"
result = isSubsequence(s, t)
print(result) # Output: True
Top comments (0)