c++ simple solution, this problem should be tagged "easy"


  • 0
    bool isSubsequence(string s, string t) {
        int sSz = s.size(),tSz = t.size(),i=0,j=0;
        while(i<sSz && j<tSz){
            if (s[i]==t[j]) i++;
            j++;
        }
        return i==sSz;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.