Search heaps hub

Hub — binary search, stacks & heaps

This topic split into focused guides — jump to binary search or stacks & heaps.

Continue here

Which tool when — comparison

This hub splits one overloaded interview bucket into two focused guides. Use the table to pick a door, then go deep.

Signal in the promptReach forGuide
Sorted array / monotone yes-no on a numberBinary search / search-on-answer Binary search
Nesting, undo, next greater/smallerStack / monotonic stack Stacks & heaps
Top-K, streaming extreme, merge K listsHeap Stacks & heaps
Need full order onceSort (not heap)—

How to study this pair

  1. Read binary search first — nail the invariant sentence.
  2. Do 2 classic BS + 2 search-on-answer problems.
  3. Then stacks & heaps — monotonic stack before heap.
  4. Do 2 next-greater + 2 top-K problems.
  5. Mix a mock that could be either (e.g. kth element — heap vs quickselect vs sort).
Interview takeaway

Open the focused post — this hub is only the map. Invariants live in the deep dives.

Shared practice set

  • Search Insert Position / First Last Position
  • Koko Eating Bananas
  • Daily Temperatures
  • Kth Largest Element
  • Top K Frequent Elements
  • Find Median from Data Stream

Pattern bank (hub links)

Eight high-yield questions across this hub — open the deep dive for full solutions.

← Lattice