Can't indexS1 be set to end instead of start?

At the very end why set indexS1 to start? The substring between start and end is guaranteed to not contain the str2 chars in order otherwise it would be a smaller subsequence than the one w just found - a contradiction. So we can safely jump indexS1 to end.

Lesson: Solution: Minimum Window Subsequence - Grokking Coding Interview Patterns in C++

1 Like

Hi @Enki
We can not set indexS1 to end instead of start. It does not work for some cases like if the string1 is equal to azstaszaztf and string2 is equal to saz if we run our code with indexS1 = end, at the very end of the code. It will return stasz instead of saz, but if you change indexS1 to start it will give you the desired output. That’s why we can not change indexS1 to end at the very end of the code.
Happy learning :slightly_smiling_face:

1 Like