# breaking it down advanced
The Watering Robot
The garden robot waters plants in a row. Its tank only holds so much — running low means marching all the way back to the tap. 🚰
Plants stand at positions 1, 2, 3… (the tap is at 0, one step apart each). You get each plant's needs in order and the tank cap (no plant needs more than a full tank). The robot walks forward one step per position, watering as it goes; if the NEXT plant needs more than what's left, it walks back to the tap, refills, and walks out again. Every step counts. Print the total steps.
Example:
Input: needs = [2, 2, 3, 3], cap = 5
Output: 14
The robot waters plants 1 and 2 (using 2 + 2 = 4 water, 2 steps in), can't afford plant 3's need of 3 with only 1 left, so it walks back to the tap and out again (extra steps), then finishes watering plants 3 and 4.