Monotonic Stack & Queue Patterns
Unresolved next-greater questions
Indices increase, values are nonincreasing. Pop while old < new, not on equality. [3,3,1,4,2] → [4,4,4,-1,-1]. An index was not resolved earlier, so its pop identifies the first greater value.
1 / 5