Dsa
Monotonic Stack
Easy
Stock Price Fluctuation Days
You are given a list of stock prices. For each price, determine the number of days until a lower price appears. If no lower price appears after the current day, return 0 for that day.
Input format:
- A single line of integers, separated by spaces, representing stock prices.
Output format:
- A single line of integers showing the number of days until a lower price appears.
Example:
Input:
150 145 160 140 135 150 135
Output:
1 1 1 1 0 1 0
Key concepts
monotonic_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