← Roadmap
Optional trackoptional
Level Up: Problem Patterns
Optional interview patterns built on the roadmap: two pointers, sliding window, prefix sums and more.
These patterns reuse arrays, linked lists and stacks from the roadmap to solve interview-style problems quickly. Finish the phase each one builds on first.
- LU.1Two PointersTwo indices that move toward each other (or in the same direction) to replace an O(n²) pair search with one O(n) pass.medium
- LU.2Sliding WindowKeep a running answer for a contiguous range, adding the item that enters and removing the one that leaves, instead of recomputing every window.medium
- LU.3Prefix SumPrecompute running totals once in O(n), then answer any range-sum query with one subtraction in O(1).easy
- LU.4Fast & Slow PointersTwo pointers moving through a linked list at different speeds find the middle, the n-th node from the end, and cycles (Floyd's algorithm) in one pass with O(1) space.medium
- LU.5Monotonic StackA stack kept in sorted (decreasing) order answers "next greater element" and "how far away is it" for every index in one O(n) pass.hard