Skip to content

#901 - Online Stock Span

MediumMonotonic Stack
Open on LeetCode

Design a class StockSpanner that collects daily price quotes and returns the span of that day's stock price. The span is the maximum number of consecutive days (starting from today going backward) where the price was less than or equal to today's price.

InputOutput
OperationsOutput
next(100), next(80), next(60), next(70), next(60), next(75), next(85)[1, 1, 1, 2, 1, 4, 6]

Released under the MIT License.