DDSA Solutions

Sliding Window

54 problems · 38 with full explanations

5 Easy27 Medium8 Hard
The sliding window technique maintains a dynamic sub-array (or substring) of interest, expanding the right boundary and shrinking the left boundary based on a constraint. It reduces O(n²) substring enumeration to O(n). Track state (frequency map, sum, distinct count) incrementally.

How to practice

To practice Sliding Window problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the sliding window pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.

Open the full study guide →

Start here (Easy + explained)

All Sliding Window problems