Pattern 6: Stack and monotonic stack/queue
Comes up in: DSA
This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.
What it covers
- matching brackets
- min-stack
- monotonic increasing/decreasing stack for "next greater"
- monotonic deque for window maximum
Words you will know
What you will practise
- valid-parentheses (E)
- min-stack (M)
- daily-temperatures (M)
- next-greater-element (M)
- sliding-window-maximum (H)
- largest-rectangle-histogram (H)
Interview questions this answers
- What is a monotonic stack and what problems does it solve?
- Find the next greater element for every item in O(n).