🎙 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 12 of 13

In the largest rectangle in a histogram, how wide can the rectangle that uses bar i's full height be?

In the largest rectangle in a histogram, how wide can the rectangle that uses bar i's full height be?

  1. A.Always the whole histogram
  2. B.Exactly one bar
  3. C.It stretches from just after the previous smaller bar to just before the next smaller bar
  4. D.Twice the height of bar i
Answer & explanation

Correct answer: It stretches from just after the previous smaller bar to just before the next smaller bar

A shorter bar on either side stops the rectangle, and the monotonic stack finds both boundaries.

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 →