2279. Maximum Bags With Full Capacity of Rocks

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2279

class Solution:
    def maximumBags(
        self, capacity: List[int], rocks: List[int], additionalRocks: int
    ) -> int:
        d = [a - b for a, b in zip(capacity, rocks)]
        d.sort()
        res = 0
        for v in d:
            if v <= additionalRocks:
                res += 1
                additionalRocks -= v
        return res