Dsa
Monotonic Stack
Medium
Temperature Anomaly Days
Given a list of temperature readings, identify for each day how many days it will take for the temperature to rise again after an anomaly (a day when the temperature is extraordinarily low).
Input Format:
- A single line containing N (1 <= N <= 100,000) followed by N integers representing the temperatures.
Output Format:
- A single line with N integers representing the number of days until a rise in temperature after each day.
Example:
Input:
7 30 20 25 24 22 23 35
Output:
2 1 1 1 1 1 0
Key concepts
monotonic_stacktemperatureanomalies
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