Preview:
class Solution {
public:
    bool isSubsequence(string s, string t) {
        int i = t.length()-1;
        int j = s.length() - 1;
        while(i>=0 & j>=0){
            if(t[i]==s[j]){
                i--;
                j--; 
            }
            else{
                i--;
            }
                       
        }
        if(j==-1){
            return true;
        }
        return false;
    }
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter