Monotonic Stack
For every value, find the next value to its right that is bigger. The obvious way compares every pair — O(n²). A monotonic stack does it in one pass.
step 01/23
- comparing
- in final place
- found it
For every value, find the next value to its right that is bigger. The obvious way compares every pair — O(n²). A monotonic stack does it in one pass.
step 01/23