力扣题-12.26
力扣题1:392. 判断子序列
解题思想:直接进行遍历即可
class Solution(object):
def isSubsequence(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
i = 0
j = 0
while j<len(s) and i <len(t):
if t[i] == s[j]:
i +=1
j +=1
else:
i +=1
if j!=len(s):
return False
return True
class Solution {
public:
bool isSubsequence(string s, string t) {
int i = 0,j = 0;
while(j < s.length() && i < t.length()){
if(t[i] == s[j]){
i++;
j++;
}
else{
i++;
}
}
if(j != s.length()){
return false;
}
return true;
}
};