【leetcode-python-16】392. 判断子序列
leetcode 392. 判断子序列
渣渣原始版(98.84%)
像是双指针吧。
class Solution(object):
def isSubsequence(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
if not s:
return True
i = 0
j = 0
while i < len(t):
if s[j] == t[i]:
j += 1
i += 1
if j == len(s):
return True
else:
return False
新手入坑,多多包涵~~