Advertisement

LeetCode 2079.给植物浇水

阅读量:

LeetCode 每日一题 ---- 【2079.给植物浇水】

  • 2079.给植物浇水
    • 方法:模拟-维护水的剩余量

2079.给植物浇水

方法:模拟-维护水的剩余量

按照浇水和灌水的程序进行操作即可。若当前存储量不低于所需水量,则每一步骤完成后步数增加1;如果当前存储量不足所需水量,则需The system must return to the starting point and refill the water tank.并且Step count must be incremented by twice the distance from current position to start point.

复制代码
    class Solution {
    public int wateringPlants(int[] plants, int capacity) {
        int len = plants.length;
        int watter = capacity;
        int ans = 0;
        int step = 0;
        for (

全部评论 (0)

还没有任何评论哟~