4Sum [Medium] — Sort + Two Pointers
Find all unique quadruplets summing to target by extending the 3Sum pattern with an outer loop and duplicate skipping.
1575 articles
Find all unique quadruplets summing to target by extending the 3Sum pattern with an outer loop and duplicate skipping.
Find minimum number of jumps to reach the last index using greedy BFS-style level tracking.
Determine the unique starting gas station for a circular route using a greedy one-pass algorithm.
LeetCode 739 — Find the number of days until a warmer temperature for each day using a monotonic decreasing stack. The key insight: store indices, not temperatures, in the stack. When a warmer day arrives, it is the "next greater element" for every cooler day still waiting on the stack — a fundamental pattern that appears in at least six other LeetCode problems.
LeetCode 128 — Find the longest consecutive integer sequence in O(n) using a HashSet. The trick: only start counting from numbers where num-1 is NOT in the set, so each element is visited at most twice total across the entire algorithm.