clueless coding // TODO: be smarter

LeetCode Is Subsequence: CPP Solution



TL;DR Code Solution


bool isSubsequence(string s, string t) {

    int si = 0;
    int ti = 0;

    while (si < s.length() && ti < t.length()) {
        if (s[si] == t[ti]) {
            si++;
        }
        ti++;
    }

    return si == s.length();

}