Mark As Completed Discussion

Now we test the window

One pointer/index corresponds to the beginning of your window, and the other corresponds to the end of the window. The first step is to move one pointer to find a valid window. This happens as we iterate through each letter, and run it through the following code block.

Test the Window
1// continue running while there's more elements in `s` to process
2if (s[end] in hash) {  // we've found a letter we needed to fulfill
3
4    // modify the length counter, we can use this as part of our substring
5    if (hash[s[end]] > 0) {
6        counter -= 1;
7    }
8
9    // modify the dictionary to say we've gotten this character requirement
10    hash[s[end]] -= 1;
11}
12
13// Keep expanding the window once we are done contracting, try more substrings
14end += 1