Skip to content

Commit 42c50ba

Browse files
authored
Update maximum-bags-with-full-capacity-of-rocks.py
1 parent c783066 commit 42c50ba

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Python/maximum-bags-with-full-capacity-of-rocks.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ def maximumBags(self, capacity, rocks, additionalRocks):
1313
for i in xrange(len(capacity)):
1414
capacity[i] -= rocks[i]
1515
capacity.sort()
16-
result = 0
17-
for c in capacity:
18-
cnt = min(c, additionalRocks)
19-
additionalRocks -= cnt
20-
c -= cnt
21-
if not c:
22-
result += 1
23-
return result
16+
for i, c in enumerate(capacity):
17+
if c > additionalRocks:
18+
return i
19+
additionalRocks -= c
20+
return len(capacity)

0 commit comments

Comments
 (0)