2024-05-08发表2025-01-15更新LeetCode每日一题几秒读完 (大约64个字)0次访问2079. 给植物浇水给植物浇水 难度: medium 原始链接: https://leetcode.cn/problems/watering-plants 标签: 贪心 解法一: 贪心go12345678910111213func wateringPlants(plants []int, capacity int) int { cur := capacity ans := 0 for i, plant := range plants { if plant > cur { ans += i << 1 cur = capacity } ans++ cur -= plant } return ans} 2079. 给植物浇水https://wuhunyu.top/leetcode/2024/05/watering-plants/index.html作者wuhunyu发布于2024-05-08更新于2025-01-15许可协议#贪心