Stock Span — Solution & Editorial
Monotonic stack of indices with strictly decreasing prices; the span stretches back to the previous strictly-greater day.
Complexity: O(N)
Monotonic stack of indices with strictly decreasing prices; the span stretches back to the previous strictly-greater day.
Complexity: O(N)