Dsa
Stack
Easy
Stock Price Tracker
You are given a list of daily stock prices in chronological order. Write a program to determine the number of days you would have to wait for a higher stock price for each day.
Input Format:
- The first line contains an integer n (1 <= n <= 1000), the number of days.
- The second line contains n space-separated integers representing the stock prices.
Output Format:
- Print a list of integers where the i-th integer represents the number of days to wait for a higher price.
Example:
Input:
5
100 80 60 70 60
Output:
0 1 1 0 0
Key concepts
stackmonotonicprice
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