2079. Watering Plants (Medium) - TengnanYao/daily_leetcode GitHub Wiki

class Solution:
    def wateringPlants(self, plants: List[int], capacity: int) -> int:
        result = 0
        i = 0
        n = len(plants)
        while i < n:
            t = capacity
            result += i
            while i < n and t >= plants[i]:
                t -= plants[i]
                i += 1
                result += 1
            if i < n:
                result += i
        return result
⚠️ **GitHub.com Fallback** ⚠️