Problems > Nearest Smaller to the Left > Editorial

Nearest Smaller to the Left — Solution & Editorial

Back to the Problem

Monotonic stack of positions with increasing values: pop everything ≥ the current element; the survivor (if any) is the answer.

Complexity: O(N)