When shrinking fails
transcript
The window method feels like a master key. It opens many problems, but not all of them. It is not a master key. Look at a sum with negative values.
The list is minus three, four, minus three. We want the longest stretch with a sum at most zero. The whole list sums to minus two. That is allowed.
The window method sees a sum of one, which is too high. It drops the minus three, and the sum rises. It ends with length one. The truth is three.
Dropping a left value must make the rule easier. A negative value breaks that promise. Products of factors at least one are safe.
Ask what dropping a left value does. Can it ever make the rule harder? If yes, use another tool, such as prefix sums.
Dropping must make the rule easier. Check that before you shrink anything. Full breakdown in the lecture.