Leetcode 392 Solution
This article provides solution to leetcode question 392 (is-subsequence)
Access this page by simply typing in "lcs 392" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/is-subsequence
Solution
class Solution {
public:
bool isSubsequence(string s, string t) {
if (s.size() == 0)
return true;
int i = 0;
int m = s.size();
int n = t.size();
for (int j = 0; j < n; j++)
{
if (s[i] == t[j])
i++;
if (i == m)
return true;
}
return false;
}
};