Skip to main content

is-subsequence

Link : https://leetcode.com/problems/is-subsequence/

var isSubsequence = function (s, t) {
if (s.length > t.length) {
return false;
}
let i = 0;
let j = 0;
while (i < s.length && j < t.length) {
if (s[i] == t[j]) {
i++;
}
j++;
}
if (i == s.length) {
return true;
} else {
return false;
}
};