chevron_leftStacks & Queues All topics

Monotonic Stack

49362817

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

Practice

spec · json ↗