Mark As Completed Discussion

So given string geography and substring graph, we'd step it through like this:

  1. g matches g, so j = 1
  2. e does not match r, so j = 0
  3. o does not match g, so j = 0
  4. g does match g, so j = 1
  5. r does match r, so j = 2
  6. a does match a, so j = 3 and so on...

At the same time, we also need to keep track of the actual index that the match starts. The j index will help us get the matching, but we need a idxOfStart variable for just the start.

Putting it all together:

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment