6-line simple cpp code

  • 0
    bool isSubsequence(string s, string t) {
            const int SL = s.length();
            if(SL == 0) return true;
            int si = 0;
            for(char ch:t)
                if(ch == s[si] && ++si == SL)
                    return true;
            return false;

Log in to reply

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