C++: 63ms, beats 99.88% of solutions


  • 0
    E
        bool isSubsequence(string s, string t) {
            int s_size=s.size();
            int last=-1;
            size_t ind;
            for(int i=0; i<s_size; i++)
            {
                ind=t.find(s[i],last+1);
                if(ind==string::npos) return false;
                else
                {
                    if(ind<max(0,last)) return false;
                    last=ind;
                }
            }
            return true;
            
        }
    

Log in to reply
 

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