Engrain by ByteRush

DSA.07 2 concepts

Binary search and stacks

Binary search on arrays and answers; monotonic stacks and queues.

  1. DSA.07.01Pattern 5: Binary search (on index and on answer)CoreMid-levelBeing written
  2. DSA.07.02Pattern 6: Stack and monotonic stack/queueCoreMid-levelBeing written

Interview questions in this module

  1. Write binary search without off-by-one errors. Explain your loop invariant.
  2. What does "binary search on the answer" mean? Give an example.
  3. What is a monotonic stack and what problems does it solve?
  4. Find the next greater element for every item in O(n).