Question bank › Stack
Dsa Stack Easy

Stock Price Span

You are given a list of daily stock prices. Implement a function to calculate the span of stock prices for each day. The span is defined as the maximum number of consecutive days (up to the current day) where the stock price was less than or equal to the current day's price. Return a list of spans as space-separated integers. Example: Input: '100 80 60 70 60 75 85', Output: '1 1 1 2 1 4 6'.

Key concepts

stackmonotonic stackarray

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.