Dsa
Monotonic Stack
Easy
Daily Temperature Variation
You are given an array of integers representing daily temperatures. For each day in the input, you want to know how many days you have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead.
Input:
- The first line contains an integer n (1 <= n <= 30000), the number of days.
- The second line contains n integers, where each integer represents the temperature (0 <= temperature <= 100).
Output:
- A single line containing n integers, the results for each day.
Example:
Input:
7
73 74 75 71 69 72 76 73
Output:
1 1 4 2 1 1 0 0
Key concepts
monotonic_stackarraystemperature
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