Mark As Completed Discussion

We do multiple things in the code block:

  1. Decrement our length counter variable to say we have one less character requirement
  2. Modify the dictionary to indicate we've fulfilled that character requirement
  3. Extend our window by incrementing end (once we can't shorten from the front)

The idea is that you continue to grow your window until you find the string that is necessary to match the problem's conditions. This is done by moving the pointers outwards and expanding the scope of your window.

In our example of “HGFDSAXZBJKC” and “ABKC”, we would look at H and do the following operations. Observe as we step through the code via comments:

1if (hash[s[end]] > 0) {  // we've found a letter we needed to fulfill
2// we're looking at `hash['H']`