Code Room
CodingEasycod-g1302
Subject Prefix sumLevel Entry–Mid~10 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A rainwater tank starts empty and has a capacity in liters. You are given the forecast daily inflow, in liters per day, as a list of integers (a maintenance drain may make a day negative). Return the index of the first day on which the cumulative total strictly exceeds the capacity, or -1 if that never happens. Example: inflows = [300, 200, 400], capacity = 800 gives 2, because the running totals are 300, 500, then 900.

Implement
overflow_day(inflows: list[int], capacity: int) → int
Examples
in[[300,200,400],800]out2
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.