Skip to content

Instantly share code, notes, and snippets.

@RP-3
Created June 9, 2020 07:20
Show Gist options
  • Save RP-3/6aa0c33787ac38c1b189866986109759 to your computer and use it in GitHub Desktop.
Save RP-3/6aa0c33787ac38c1b189866986109759 to your computer and use it in GitHub Desktop.
/**
* @param {string} s
* @param {string} t
* @return {boolean}
*/
var isSubsequence = function(s, t) {
if(!s.length) return true;
let i = 0;
for(let j=0; j<t.length; j++){
if(t[j] !== s[i]) continue;
if(++i === s.length) return true;
}
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment