class Solution(object):
def isSubsequence(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
if not s:
return True
if not t:
return False
sIndex = 0
tIndex = 0
while sIndex < len(s) and tIndex < len(t):
if s[sIndex] == t[tIndex]:
sIndex += 1
tIndex += 1
else:
tIndex += 1
if sIndex == len(s):
return True
else:
return False
s = Solution()
s1 = "abc"
t1 = "ahbgdc"
s2 = "axc"
t2 = "ahbgdc"
print s.isSubsequence(s1,t1)
print s.isSubsequence(s2,t2)
贪心_leetcode392
猜你喜欢
转载自www.cnblogs.com/lux-ace/p/10556848.html
今日推荐
周排行