Dsa
Monotonic Stack
Easy
Daily Temperature Forecast
Given an array of daily temperatures, return an array such that for each day in the input array, you find the number of 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 n integers, representing temperatures, separated by spaces.
Output Format:
- A single line containing n integers, representing the awaited warmer days, separated by spaces.
Example:
Input:
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