Leetcode: Problem #2 — Validate Subsequence

While Loop Approach

A solution that utilizes a single while loop

For-Loop Approach

A solution that utilizes a single for loop
  1. If the value in the sequence array at the sequenceIndex is equal to the current value we are iterating in our given input array, then we want to increment the sequenceIndex by 1, which goes back to what we discussed earlier about the sequenceIndex serving as a count.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
John Kim

John Kim

75 Followers

iOS Developer | Full Stack Developer | Software Engineer | LinkedIn: john-kim-developer | GitHub: cloudiosx | Portfolio: cloudiosx.com