Maximum Bags With Full Capacity of Rocks
You have n
bags numbered from 0
to n - 1
. You are given two 0-indexed integer arrays capacity
and rocks
. The ith
bag can hold a maximum of capacity[i]
rocks and currently contains rocks[i]
rocks. You are also given an integer additionalRocks
, the number of additional rocks you can place in any of the bags.
Return the maximum number of bags that could have full capacity after placing the additional rocks in some bags.
So first of all you have given rocks and you need to serve rocks to bag and make bag FULL.
For that you have to find out which has less empty spaces among those bags and start filling rocks from that bags. So, First we will sort bags according to empty spaces. After that, start adding rocks from that manner. Parallelly, Increment the count.
If you have any doubt or any suggestion, Please don’t hesitate to reach out to me. Suggestion are welcomed.