Module 7 · Sliding Window · Common Mistakes

Sliding Window: common mistakes

The grow / measure / shrink template has three places to slip: what you measure, how you count what's in the window, and where its edges are. Here: measuring a window that still holds its repeated letter, a letter whose count reached 0 still counted, and r - l instead of r - l + 1. The window is l to r - 1.

Pick a mistake and press play: Wrong runs the code with the mistake until it breaks, and the code marks the wrong line in red. Fixed runs the corrected code on the same input, with the corrected line in green.

Mistake
Code