dsa2 min read
Daily Temperatures — Monotonic Decreasing Stack
Find how many days until a warmer temperature using a monotonic decreasing stack of unresolved day indices.
Read →
webcoderspeed.com
1276 articles
Find how many days until a warmer temperature using a monotonic decreasing stack of unresolved day indices.
Find the next greater element for each query in O(n+m) using a monotonic stack on nums2 and a lookup map.
Find the next greater element in a circular array by iterating twice (0 to 2n) and using a monotonic stack.
Calculate the stock price span (consecutive days <= today) using a monotonic stack that accumulates spans.
Remove k digits to form the smallest number by maintaining a monotonic increasing stack and greedy removal.