Question bank › Monotonic Stack
Dsa Monotonic Stack Easy

Daily Weather Trend

You are given a list of daily weather temperatures for the next week. For each day, find out how many days you will have to wait until a hotter day. If there is no hotter day in the future, return 0 for that day. Your program should read the number of days and then the temperatures, and for each day, print the number of days until a hotter day. Input format: The first line contains an integer n (1 <= n <= 100), the number of days. The second line contains n integers, each between -30 and 50, representing the temperatures. Output format: Print n integers as space-separated values, where each integer is the number of days until a hotter day, or 0 if no such day exists. Example: Input: 7 30 32 34 31 29 35 40 Output: 1 1 3 1 1 1 0

Key concepts

monotonic_stackarrayweather

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.