Dsa
Monotonic Stack
Easy
Stock Price Views
You are monitoring stock prices and need to calculate how many consecutive days each price was less than or equal to the current day's price. For each day, print the count of previous days with a lesser or equal price. The input is a single line containing space-separated integers representing the stock prices.
Example:
Input:
100 80 60 70 60 75 85
Output:
1 1 1 2 1 3 5
Key concepts
monotonic_stackarrayfinance
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