← 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?
- A.A min-heap
- B.Binary search
- C.A hash map of prices
- 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 →