Question bank › Monotonic Stack
Dsa Monotonic Stack Medium

Daily Temperature Fluctuations

You are tasked with analyzing daily temperature fluctuations over a week. Given an array where each element represents the temperature for a day, you need to determine how many days it will take for a day to become warmer than each respective day. If there is no future day that is warmer, output 0 days. Write a program that reads an integer n (the number of days) followed by n integers representing the daily temperatures. Print a single line with n integers representing the count of days until a warmer temperature for each day. Input format: - The first line contains a single integer n (1 <= n <= 100000). - The second line contains n space-separated integers representing the daily temperatures. Output format: - A single line with n space-separated integers, the days until the next warmer day. Example: Input: 5 73 74 75 71 69 Output: 1 1 0 0 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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.