Skip to content

Latest commit

 

History

History
21 lines (20 loc) · 402 Bytes

lyan_dut.md

File metadata and controls

21 lines (20 loc) · 402 Bytes
/*
 * 392. 判断子序列
 * https://leetcode-cn.com/problems/is-subsequence/
 */
/*
 * 方法一: 双指针
 */
bool MyLeetCode::isSubsequence(string s, string t) {
    if(s.length()==0 && t.length()==0)
        return true;
    for(int i=0, j=0; j < t.length(); j++){
        if(s[i] == t[j])
            i++;
        if(i==s.length())
            return true;
    }
    return false;
}