Lesson 4 of 23 ยท 14 min ยท 2 hands-on steps

The Monotonic Stack

Find the "next greater" or "next smaller" element for every item in one pass.

Unlock โ€œThe Monotonic Stackโ€

Plus 1,080 more interview questions with step-through solutions and 36 advanced lessons in algorithms, systems and system design.

$39/yearabout 11ยข a day ยท one payment, no monthly billsLeetCode Premium alone is $159/year.
See everything included

๐Ÿ›ก๏ธ 14-day money-back guarantee. Already a member? Log in