Sliding Window & Two Pointers
A sliding window keeps a range of an array or string and moves its two ends forward instead of re-checking every subarray. Two pointers is the same habit applied to one or two sequences at once. Both turn many brute-force scans into a single pass.
The six chapters start with fixed-length windows, move on to windows that grow and shrink, then cover two pointers on one sequence, two pointers on two sequences, three pointers, and grouped iteration. It is the first plan on the route, so it suits anyone starting LeetCode or coming back after a break.
Want company while you work through this list? Sign in, open the study room, and your heroine will bring you the problems one at a time.
I. Fixed-Length Sliding Window
§1.1 Fundamentals
§1.2 Advanced (Optional)Optional
§1.3 Miscellaneous (Optional)Optional
II. Dynamic-Length Sliding Window
§2.1 Shorter is Valid / Maximize Length
§2.2 Longer is Valid / Minimize Length
§2.3 Counting Subarrays
§2.4 Miscellaneous (Optional)Optional
III. Single-Sequence Two Pointers
§3.1 Opposite Direction Two Pointers
§3.2 Same Direction Two Pointers
§3.3 Two Pointers Expanding Outward
| Problem | Rating |
|---|---|
| 1793. Maximum Score of a Good Subarray | 1946 |
| 976. Largest Perimeter Triangle | 1263 |
§3.4 In-Place Modification
IV. Two-Sequence Two Pointers
§4.1 Two Pointers
§4.2 Subsequence Validation
V. Three Pointers
Fundamentals
Advanced Explorations
| Problem | Rating |
|---|---|
| 3464. Maximize the Distance Between Points on a Square | 2806 |
VI. Grouped Iteration
Fundamentals
Every new route opens at the first section of this plan, and its three optional sections are marked and saved for the advanced lists, so they never hold you back.
Ratings come from zerotrac's LeetCode contest ratings. Some problems have no zerotrac rating and are marked Unrated.
Open the study room