Dsa
Monotonic Stack
Easy
Next Greater Temperature
Given a list of daily temperature readings, return a list where each element at index i is the number of days until a warmer temperature. If there is no future day for which this is possible, put 0 instead.
Input Format:
- A single line of space-separated integers representing daily temperatures.
Output Format:
- A single line of space-separated integers representing the days until a warmer temperature for each day.
Example:
Input:
70 72 69 68 75 71 80
Output:
1 1 3 1 0 1 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