Two Pointers
Scan a sorted array or string from both ends at once to find pairs, remove duplicates, or reverse data in O(n).
Solve fixed-window problems: maximum sum of k elements, moving averages, and O(n) updates as the window slides.
Find the contiguous subarray of a fixed length with the largest average.
Find the maximum sum of any contiguous subarray of exactly size k.
Check whether any value repeats inside a distance of at most k indices.
Find the maximum vowel count inside any substring of a fixed length k.
Count fixed-size subarrays whose average is at least a given threshold.
Find the maximum profit from buying on one day and selling on a later day.
Pick k scores from a list so the gap between the highest and lowest picked is as small as possible.
Count substrings of length three whose characters are all different.
Replace every value in a circular array with the sum of a fixed run of its neighbors.
Find the length of the longest run of characters in a string with no repeats.
Check whether one string contains a rearrangement of another string as a substring.
Find the shortest contiguous subarray whose sum is at least a target value.
Find the longest substring you can turn into one repeated letter with a limited number of swaps.
Find the longest run of fruit you can collect while carrying only two types at once.
Find the longest run of 1s you can make by flipping a limited number of 0s.
Find every start index where a substring is an anagram of another string.
Maximize satisfied customers by calming a grumpy owner for one fixed stretch of minutes.
Find the longest contiguous subarray where any two values differ by at most a limit.
Count subarrays of a binary array whose values sum to exactly a target.
Count contiguous subarrays whose product of elements is strictly less than k.
Count subarrays that contain exactly k odd numbers.
Delete exactly one element and find the longest run of 1s left in the array.
Increase array values up to a total budget to maximize how many end up equal.
Take exactly k cards from either end of a row to maximize their total value.
Find the longest substring you can change into another string within a total cost budget.
Find the shortest substring you can replace so every character appears an equal number of times.
Find the shortest substring of one string that contains every character of another string.
Find the maximum value inside every fixed-size window as it slides across an array.
Find every starting point where a string is formed by joining all given words in any order.
Find the longest substring that uses at most k distinct characters.
Count contiguous subarrays that contain exactly k different integers.
Find the median of every fixed-size window as it slides across an array.
Find the fewest length-k flips needed to turn every 0 in a binary array into a 1.
Find the length of the shortest contiguous subarray whose sum is at least k, with negatives allowed.
Scan a sorted array or string from both ends at once to find pairs, remove duplicates, or reverse data in O(n).
Cut a sorted range in half on every step to find a value or boundary in O(log n) instead of checking one by one.
Explore as far as possible down one path before backtracking, used to walk trees, graphs, and grids.
Explore level by level from a starting point, the go-to way to find the shortest path in an unweighted graph.
Break a problem into overlapping subproblems and reuse their answers to avoid recomputing the same work.
Try a choice, keep going, and undo it if it fails, used to generate permutations, combinations, and valid layouts.