class Solution { public: bool isSubsequence(string s, string t) { int si = 0; // s index int ti = 0; // t index int matches = 0; while ( ( matches != s.size() ) && (ti != t.size()) ) // does loop until matches = s.size() or t index reaches end of t string { if (s[si] == t[ti]) { matches++; si++; } ti++; } cout << "Matches = " << matches ; return (matches == s.size()); } };