C++ 59ms


  • 0
    F

    C++ 59ms

    class Solution {
    public:
        bool isSubsequence(string s, string t) {
            int index_s=0;
            int index_t=0;
            
            for(;index_s<s.size();++index_s)
            {   
                if(index_t>t.size()-1)
                    return false;
                    
                size_t tmp=t.find_first_of(s[index_s],index_t);
                if(tmp!=string::npos)
                    {
                        tmp++;
                        index_t=tmp;
                    }
                else
                    return false;
            }
            
            return true;
    
    }
    

    };


Log in to reply
 

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