Skip to content

Instantly share code, notes, and snippets.

@MohdSaifulM
Created November 7, 2022 16:28
Show Gist options
  • Save MohdSaifulM/ce0c031b31642a96bd2d4f3f90fcc674 to your computer and use it in GitHub Desktop.
Save MohdSaifulM/ce0c031b31642a96bd2d4f3f90fcc674 to your computer and use it in GitHub Desktop.
Algorithms - Multiple Pointers
function isSubsequence(first, second) {
if (first.length > second.length) return false;
if (!first) return true;
let i = 0;
let j = 0;
while (j < second.length) {
if (first[i] === second[j]) i++;
if (i === first.length) return true;
j++;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment