Skip to content
dsa/roadmap
← Home
Optional trackAnytime ~3.5 hnot on the exam

Level Up: Problem Patterns

Optional interview patterns built on this course. Not on the exam.

These patterns reuse arrays, linked lists and stacks from the course to solve interview-style problems quickly. Finish the chapter they build on first. They will make you faster at the exam's "write a function" questions, but nothing here is examined directly.

  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. 40 minmedium
  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. 45 minmedium
  3. LU.3Prefix SumPrecompute running totals once in O(n), then answer any range-sum query with one subtraction in O(1). 35 mineasy
  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. 40 minmedium
  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. 50 minhard

Keyboard shortcuts

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