https://leetcode.com/problems/is-subsequence

Source


    bool isSubsequence(string s, string t) {
        if (s.size() == 0) return true;
        bool isSubsq = false;
        int i = 0;
        for (const auto &c : t) {
            if (c == s[i]) {
                ++i;
                if (s.size() == i) {
                    isSubsq = true;
                    break;
                } else
                    continue;
            }
        }
        return isSubsq;
    }

GitHub

IsSubsequence