When to Use Monotonic Stack

Use monotonic stack when:

1.1. You need the next/previous greater or smaller element for each position

2.2. You're computing contribution of each element as min/max of subarrays

3.3. You see histogram-like problems with heights and widths

4.4. You need to track "visible" elements or blocking relationships

Here's what matters: when an element gets popped, the new top is its previous greater/smaller, and the pushing element is its next greater/smaller.