Search
⌘K

Leetcode 901. Online Stock Span

Given a stream of daily stock prices, implement an online data structure that returns for each new price the number of consecutive days (including today) the price was less than or equal to the current price. The common optimal approach uses a monotonic decreasing stack that aggregates spans to achieve amortized O(1) time per query.

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid February, 2025

Meta

Mid-level

Comments

Your account is free and you can post anonymously if you choose.