0392.cpp (224B)
1 class Solution { 2 public: 3 bool isSubsequence(string s, string t) { 4 int i = 0; 5 for (int j = 0; j < t.size() && i < s.size(); j++) 6 if (s[i] == t[j]) i++; 7 return i == s.size(); 8 } 9 };