🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Monotonic Stack: all 13 questions

Quiz: Monotonic Stack · Question 13 of 13

"For each day, how many consecutive days up to today had a price ≤ today's price?" (the stock span problem). Which tool…

"For each day, how many consecutive days up to today had a price ≤ today's price?" (the stock span problem). Which tool fits?

  1. A.A min-heap
  2. B.Binary search
  3. C.A hash map of prices
  4. D.A monotonic stack that finds the previous greater price
Answer & explanation

Correct answer: A monotonic stack that finds the previous greater price

The span is the distance back to the previous day with a strictly greater price, one of the four stack variants.

Can you get the rest right without peeking?

Take the timed Quiz: Monotonic Stack quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →