Maximum Bags With Full Capacity of Rocks

You have n bags numbered from 0 to n - 1. The bag i can hold a maximum of capacity[i] rocks and currently contains rocks[i] rocks. There are additionalRocks number of additional rocks you can place in any of the bags. The task is to find the maximum number of bags that can reach full capacity after placing the additional rocks in some bags.

Constraints

  • n == capacity.length == rocks.length
  • 1 <= n <= 5 * 10^4
  • 1 <= capacity[i] <= 10^9
  • 0 <= rocks[i] <= capacity[i]
  • 1 <= additionalRocks <= 10^9
Saving… · 2 lines
class Solution:
def maximumBagsWithFullCapacityOfRocks(self, capacity, rocks, additionalRocks) -> int:
Console

Click Run to execute sample tests.