← AlgoMindset 75

Online Stock Span

Medium🎙 Interview me on this

🧠 Before you code — what pattern fits?

Implement StockSpanner: next(price) returns the span of today's price — the number of consecutive days (ending today, going backward) the price was less than or equal to today's price.

next(100)=1, next(80)=1, next(60)=1, next(70)=2, next(60)=1, next(75)=4, next(85)=6

🎬 Video explanation · NeetCode

Your solution runs against 1 unit tests, including edge and large-value cases.

Loading...

Test console · 1 unit tests

Submit your code to run it against all 1 unit tests. Results appear here.

JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.