Simple C Recursive Solution

  • 0

    Greedy recursive algorithm:
    If there's nothing left to check, it's valid.
    Look for the char in t,
    If there's chars to check, but none of t left, it's invalid.
    else try the next char of t


    bool isSubsequence(char* s, char* t) {
        if (*s=='\0'){
            return true;
                return false;
            t = t + 1;
        return isSubsequence(s+1, t+1);

Log in to reply

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