Mark As Completed Discussion

We'll proceed with the above logic until we get all the required letters that we needed, which is directed by while counter == 0:. Once we find the substring containing all the letters we need, we can then proceed since we've found a valid condition.

We're now sure that we've covered all the letters we need, but our window may be bigger than we need it to be. We can then shrink our window until we do not have a valid substring. Here's the code block for when we find a letter in the substring that isn't necessary.

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