This commit is contained in:
bobbert committed 2026-05-09 21:37:38 +01:00
1 parent f0643a0f10
commit 5d2c2664cc
1 file changed
+23
@@ -0,0 +1,23 @@
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());
}
};