Created
June 5, 2017 16:32
-
-
Save alexitaylor/9ac461f225bb55617b6248f4e1951820 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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