Dsa
Monotonic Stack
Easy
Next Higher Temperature
Given a list of daily temperatures, produce a list of integers such that, for each day in the input list, you determine 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 format:
- A single line containing space-separated integers representing daily temperatures.
Output format:
- A single line containing space-separated integers representing the number of days to wait for a warmer temperature.
Example:
Input:
70 71 69 72 73 69 68 75
Output:
1 1 1 1 0 1 1 0
Key concepts
monotonic_stackarraytemperature
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