Dsa
Monotonic Stack
Hard
Temperature Trend Analysis
You are given an array of integers representing daily temperatures. For each day in the input, count the number of days until a warmer temperature occurs. If no warmer temperature occurs, record a zero instead.
Input format:
- A single line of space-separated integers representing temperatures (0 <= temp <= 100).
Output format:
- A single line containing space-separated integers indicating the count of days until a warmer temperature.
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