Plant watering steps
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.
Implement
watering_steps(plants: list[int], capacity: int) → intExamples
in
[[2,2,3,3],5]out14What 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.
0:00 of about 14 min
solution.py
InputExpectedGot
[[2,2,3,3],5]14not run yetsample