DSA Pattern Guide
Sliding Window & Two Pointers Guide
Sliding window and two pointers both avoid nested loops by moving one or two indices through an array in a single pass instead of re-scanning. Sliding window grows/shrinks a contiguous range to satisfy a condition (longest substring without repeats, smallest subarray with a given sum); two pointers usually start at opposite ends and move inward (sorted-array pair sums, reversing in place).
2
Sliding-window-tagged problems in Ediky's DSA bank
3
Two-pointer-tagged problems in Ediky's DSA bank
Being upfront: neither "Sliding Window" nor "Two Pointers" is a dedicated topic in Ediky's DSA bank yet — they exist only as tags on a handful of Array/DP problems (5 total), so there's no precise one-click filtered list to link to. The CTA below goes to the Array topic (where most of these problems live) — once there, search "sliding window" or "two pointers" in the search box to find the tagged subset directly, since search does match tags. The 600-problem CP sheet has 27 dedicated "Two Pointers" problems, but that list view was retired from the website, so it isn't linkable here either.
The patterns that matter
- Fixed-size sliding window — track a running aggregate (sum, count) as a fixed-width window moves
- Variable-size sliding window — grow the window until a condition breaks, then shrink from the left
- Two pointers from opposite ends — sorted-array pair-sum problems, palindrome checks, in-place reversal
- Two pointers moving in the same direction — deduplication, partitioning, subarray removal
Real problems from Ediky's DSA bank
Actual tagged problem titles:
- "Minimum Subarray Length in Infinite Array" (sliding window)
- "Losing Chess Strategy" (sliding window)
- "Subarray Removal" (two pointers)
- "Subarray Mexes" (two pointers)
Find sliding window & two pointer problems
Open Array problems, then search "sliding window" or "two pointers" — there's no dedicated topic filter for these yet.
Open Array problems