- Wrong monotonic direction: Increasing stack for next greater, decreasing for next smaller.
Mixing these gives wrong answers.
- Not handling equal elements correctly: Decide whether equal elements should be popped or kept based on problem requirements.
- Forgetting to process remaining stack: Elements left in stack at end need special handling (often they have no next greater/smaller).
- Off-by-one in index calculations: When computing distances or spans, carefully handle whether boundaries are inclusive or exclusive.