[LeetCode] 2079. Watering Plants

김민우·2022년 12월 10일
0

알고리즘

목록 보기
82/189

- Problem

2079. Watering Plants


- 내 풀이

class Solution:
    def wateringPlants(self, plants: List[int], capacity: int) -> int:
        answer = 0
        water = capacity
        
        for i, v in enumerate(plants):
            if water - v < 0:
                answer += i * 2
                water = capacity
                
            water -= v
            answer += 1
        
        return answer

- 결과

profile
Pay it forward.

1개의 댓글

comment-user-thumbnail
2024년 6월 3일

Cooking with vegetables has never been easier with Veggie Knowledge. Our site features a wide range of recipes that highlight the flavors and health benefits of vegetables. Start cooking delicious and nutritious meals today. advice for growing vegetables

답글 달기