Dsa
Monotonic Stack
Hard
Next Warmer Day
Given an array consisting of temperatures on different days, you need to determine how many days it will take for each day's temperature to rise to a warmer temperature. If it never rises, the output for that day should be '0'.
Input format:
- A single line of space-separated integers representing temperatures (0 <= temperature <= 120).
Output format:
- A single line of space-separated integers with the days until a warmer day.
Example:
Input:
70 72 68 75 73
Output:
1 4 1 0 0
Key concepts
monotonic_stackweatherarray
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