Leetcode 392 Solution

This article provides solution to leetcode question 392 (is-subsequence)

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; } };