Dsa
Monotonic Stack
Easy
Rainfall Predictions
You have been tasked with predicting rainfall based on a series of measurements taken over several days. For each day, determine how many days it will take until a day with equal or more rainfall occurs. If there isn't such a day, report -1 for that day.
Input Format:
- A single line with space-separated integers representing rainfall measurements for consecutive days.
Output Format:
- A single line of space-separated integers representing the wait days for more or equal rainfall.
Example:
Input:
1 2 1 3 2 1
Output:
1 3 1 0 0 -1
Key concepts
monotonic_stackrainfall
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