📖 Core Idea: A monotonic stack keeps elements in strictly increasing or decreasing order. As you iterate, you pop elements that violate the order and use the popped results to answer “next greater/smaller” questions efficiently in a single pass.
🗯Real Interview Scenario: “Next Greater Element”, “Daily Temperatures”, or “Largest Rectangle in Histogram”.
✅ How to shine: Say:
I’ll maintain a monotonic decreasing stack of indices to find the first larger element in O(n) time
Explain why you traverse right-to-left for next greater. Dry-run a small example out loud. Interviewers love this clarity.