C++ solution easy to understand


  • 0
    S

    class Solution {
    public:
    bool isSubsequence(string s, string t) {
    int start=0;
    for(int i=0;i<s.length();i++){
    bool f= false;
    for(int j=start;j<t.length();j++){
    if(s[i]==t[j]){f=true;start=j+1;break;}
    }
    if (!f) return false;
    }
    return true;
    }
    };


Log in to reply
 

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