DOKICODE
Study room

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.

194 problemsRating 1165–28066 Chapters
Open the study room

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

II. Dynamic-Length Sliding Window

III. Single-Sequence Two Pointers

§3.3 Two Pointers Expanding Outward

ProblemRating
1793. Maximum Score of a Good Subarray1946
976. Largest Perimeter Triangle1263

IV. Two-Sequence Two Pointers

V. Three Pointers

Advanced Explorations

ProblemRating
3464. Maximize the Distance Between Points on a Square2806

VI. Grouped Iteration

Fundamentals

ProblemRating
485. Max Consecutive Ones1263
1446. Consecutive Characters1165
1869. Longer Contiguous Segments of Ones Than Zeros1205
2414. Length of the Longest Alphabetical Continuous Substring1222
3456. Find Special Substring of Length K1244
2273. Find Resultant Array After Removing Anagrams1295
2348. Number of Zero Filled Subarrays1316
1513. Number of Substrings with Only 1s1351
1957. Delete Characters to Make Fancy String1358
674. Longest Continuous Increasing Subsequence1263
3708. Longest Fibonacci Subarray1381
696. Count Binary Substrings1263
978. Longest Turbulent Subarray1393
2110. Number of Smooth Descent Periods of a Stock1408
228. Summary Ranges1263
2760. Longest Even Odd Subarray with Threshold1420
1887. Reduction Operations to Make the Array Elements Equal1428
845. Longest Mountain in Array1437
2038. Remove Colored Pieces If Both Neighbors Are the Same Color1468
2900. Longest Unequal Adjacent Groups Subsequence I1469
1759. Count Number of Homogenous Substrings1491
3011. Find If Array Can Be Sorted1497
1578. Minimum Time to Make Rope Colorful1574
1839. Longest Substring of All Vowels in Order1580
2765. Longest Alternating Subarray1581
3255. Find the Power of K Size Subarrays II1595
3350. Adjacent Increasing Subarrays Detection II1600
3105. Longest Strictly Increasing OR Strictly Decreasing Subarray1600
838. Push Dominoes1638
467. Unique Substrings in Wraparound String1700
3499. Maximize Active Section with Trade I1729
413. Arithmetic Slices1263
68. Text Justification1263
135. Candy1263
2948. Make Lexicographically Smallest Array by Swapping Elements2047
2593. Find Score of an Array After Marking All Elements1263
3640. Trionic Array II2278

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