s4553711
5/16/2017 - 2:36 PM

392.cpp

class Solution {
public:
    bool isSubsequence(string s, string t) {
        if (s.length() == 0) return true;
        int i = 0, j = 0;
        while (i < s.length() && j < t.length()) {
            if (s[i] == t[j]) {
                i++;
            }
            j++;
        }
        return i == s.size();
    }
};