Dsa
Prefix Sum
Easy
Reservoir Storm Watch
A weather station monitors daily rainfall. A 'Storm Alert' is triggered for any contiguous period of D days where the total rainfall exceeds a threshold T. Given N days of rainfall data, calculate how many unique D-day periods would have triggered a Storm Alert.
Input Format:
- Line 1: Three integers N (total days), D (period length), and T (threshold).
- Line 2: N integers representing daily rainfall.
Output Format:
- A single integer representing the count of D-day periods exceeding T.
Example:
Input:
5 2 10
6 5 4 8 2
Output:
2
Key concepts
prefix_sumfixed_window
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