Monotonic stack
A stack whose items are kept in increasing or decreasing order, popping items that break the order as new ones arrive. It is used for "next bigger value" questions.
A stack whose items are kept in increasing or decreasing order, popping items that break the order as new ones arrive. It is used for "next bigger value" questions.