题解 | #判断子序列#
判断子序列
http://www.nowcoder.com/practice/39be6c2d0a9b4c30a7b04053d5960a84
双指针判断
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param S string字符串
# @param T string字符串
# @return bool布尔型
#
class Solution:
def isSubsequence(self , S: str, T: str) -> bool:
# write code here
si = ti = 0
while ti < len(T):
if T[ti] == S[si]:
si += 1
if si == len(S):
return True
ti += 1
return False
题解 文章被收录于专栏
算法题解