Question
A water tank logs one signed flow value per minute: positive means water in, negative means water out. An auditor wants to know how many contiguous stretches of minutes had a net flow of exactly k liters. Count every such stretch (non-empty, any length, any starting minute). Flows and k may be zero or negative, so stretches can overlap and shorter stretches inside longer ones count separately. Example: flows = [2, -2, 2, -2], k = 0 gives 4.
count_net_stretches(flows: list[int], k: int) → int[[2,-2,2,-2],0]out4State 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.