1
class Solution {
2
public int wateringPlants(int[] plants, int capacity) {
3
int count = 0, c = capacity;
4
for (int i = 0; i < plants.length; i++) {
5
if (c >= plants[i]) {
6
c -= plants[i];
7
count++;
8
} else {
9
c = capacity;
10
count = count + i + (i + 1);
11
c -= plants[i];
12
}
13
}
14
return count;
15
}
16
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0