2079. Watering Plants
On This Page
class Solution:
def wateringPlants(self, plants: List[int], capacity: int) -> int:
res, cap = 0, capacity
for i, x in enumerate(plants):
if cap >= x:
cap -= x
res += 1
else:
cap = capacity - x
res += i * 2 + 1
return res