Question
You water a row of office plants left to right using a can that holds capacity units. plants[i] is how much water plant i needs (each need is at most capacity). The tap sits one step left of plant 0; you start there with a full can. Walking between adjacent positions costs one step, watering itself is free, and you only ever water the next unwatered plant. If the can holds too little for that plant you must first walk back to the tap, refill, and walk out again. Return the total steps taken to water every plant.
watering_steps(plants: list[int], capacity: int) → int[[2,2,3,3],5]out14State 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.