Groups
Category
A monotonic deque is a double-ended queue that keeps elements in increasing or decreasing order so that the front always holds the current optimum (min or max).
A monotonic stack is a stack that keeps its elements in increasing or decreasing order to answer range queries in linear time.