Dsa
Monotonic Stack
Medium
Daily Rain Prediction
Given an array representing daily rain levels, find the number of days until the rain level increases for each day. If there is no future day with more rain, output 0.
Example Input:
6
0 0 10 0 5 15
Example Output:
2 1 0 1 1 0
Input Format:
- The first line contains an integer n (1 ≤ n ≤ 30000), the number of days.
- The second line contains n space-separated integers, representing the rain levels.
Output Format:
- A single line of n integers indicating the number of days until rain increases for each day.
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