Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
imteekay committed Nov 27, 2023
1 parent 4138620 commit 624a55b
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function isValidSubsequence(array, sequence) {
let p1 = 0;
let p2 = 0;

while (p1 < array.length && p2 < sequence.length) {
if (array[p1] === sequence[p2]) {
p1++;
p2++;
} else {
p1++;
}
}

return p2 === sequence.length;
}

0 comments on commit 624a55b

Please sign in to comment.