Skip to content

Instantly share code, notes, and snippets.

@alexitaylor
Created June 5, 2017 16:32
Show Gist options
  • Save alexitaylor/9ac461f225bb55617b6248f4e1951820 to your computer and use it in GitHub Desktop.
Save alexitaylor/9ac461f225bb55617b6248f4e1951820 to your computer and use it in GitHub Desktop.
/**
* @param {string} s
* @param {string} t
* @return {boolean}
*/
var isSubsequence = function(s, t) {
var indexCount = 0;
if (s === "") {
return true;
}
for (var i = 0; i < t.length; i++) {
if (t[i] === s[indexCount]) {
if (indexCount === s.length - 1) {
return true;
}
indexCount++;
}
}
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment