Question bank › Prefix Sum
Dsa Prefix Sum Warm-up

Rainfall Milestone

A meteorologist tracks daily rainfall in millimeters for N days. They want to find the first day on which the total accumulated rainfall reached or exceeded a target value T. Output the 1-based index of the day, or -1 if the target was never reached. Input Format: The first line contains two integers: N (total days) and T (target rainfall). The second line contains N integers representing rainfall per day. Output Format: A single integer (the 1st day the target is met) or -1. Example: Input: 4 100 30 40 20 15 Output: 4 (Explanation: Days: 30, 70, 90, 105. At day 4, 105 >= 100.)

Key concepts

prefix_sumsearch

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.