Skip to content
dsa/roadmap
← 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.

  1. 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
  2. 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
  3. LU.3Prefix SumPrecompute running totals once in O(n), then answer any range-sum query with one subtraction in O(1).easy
  4. 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
  5. 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

Keyboard shortcuts

⌘K /
Search topics, glossary, cheat sheets
space
Play / pause the visualizer
← →
Step back / forward
r
Reset the visualizer
?
Show this help