What is a Monotonic Stack?

Alex Zelinsky
Level Up Coding
Published in
4 min readAug 23, 2022

--

Photo by Malte Helmhold on Unsplash

A monotonic stack is a variation of the stack data structure in which the elements are always sorted in a specific order. In a monotonic stack, the elements must be all monotonic increasing or monotonic decreasing. Monotonic stacks come up in coding interviews frequently, making them an important concept for interviewees to understand. In this article, we’ll discuss what monotonic stacks are, how they work, and some of their applications.

--

--