玩緊個啲咩15日challenge
beginner level 都題題個幾鐘 想喊
仲要係垃圾曲 好後悔讀U個時冇認真學 algorithm
後面個啲topic 直情冇聽過
392. Is Subsequence
Given two strings s and t, return true if s is a subsequence of t, or false otherwise.
A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not).
Runtime: 28 ms, faster than 98.23% of Python3 online submissions for Is Subsequence.
Memory Usage: 13.9 MB, less than 43.99% of Python3 online submissions for Is Subsequence.
class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
if len(s) == 1 and s not in t:
return False
for i in range(0,len(s)):
if s[i] not in t:
return False
t = t[t.index(s[i])+1:]
return True