We use cookies for site analytics. Accept to help us understand how the site is used. See our Privacy Policy for details.
A hard sliding window problem, graded against 6 test cases (3 of them hidden).
A moving window over a contiguous run, expanding and contracting to hold an invariant.
Reach for it when you see: "Longest/shortest contiguous subarray or substring satisfying X."
More Sliding Windowproblems →Use two pointers (left, right) to define a window. Expand right until all characters are covered, then shrink left while maintaining coverage.
The full reference solution in every supported language stays in the editor above - reveal it there once you have had a real attempt.
These apply to the pattern as a whole, not just this problem.