We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3b30770 commit 7658a64Copy full SHA for 7658a64
scripts/algorithms/W/Watering Plants/Watering Plants.py
@@ -1,15 +1,16 @@
1
+# Runtime: 93 ms (Top 33.43%) | Memory: 14.1 MB (Top 44.38%)
2
class Solution:
- def wateringPlants(self, plants: List[int], capacity: int) -> int:
3
- result = 0
4
- curCap = capacity
+ def wateringPlants(self, plants: List[int], capacity: int) -> int:
+ result = 0
5
+ curCap = capacity
6
- for i in range(len(plants)):
7
- if curCap >= plants[i]:
8
- curCap -= plants[i]
9
- result += 1
+ for i in range(len(plants)):
+ if curCap >= plants[i]:
+ curCap -= plants[i]
10
+ result += 1
11
- else:
12
- result += i * 2 + 1
13
- curCap = capacity - plants[i]
+ else:
+ result += i * 2 + 1
14
+ curCap = capacity - plants[i]
15
- return result
16
+ return result
0 commit comments