Monotonic stack: next greater element
Solve 'next greater/smaller' problems in O(n).
Lesson complete
Nice work. Replay it any time.
About this topic
Solve 'next greater/smaller' problems in O(n).
Part of Data Structures & Algorithms (C++): 25 topics, 5 free.