Next greater element (monotonic stack)
Keep a stack of values still waiting for something bigger; each value is pushed and popped once.
Values4, 5, 2, 25, 7, 18
For each value in 4, 5, 2, 25, 7, 18, find the first bigger value to its right.
- compare
- swap or write
- settled
Space play · ← → step · Home End jump · drag the strip to scrub