Trains the technique from
LeetCode 2279Maximum Bags With Full Capacity of RocksThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A yard holds n crates. Crate i takes capacity[i] bricks in total and already holds rocks[i] of them. A delivery brings additionalRocks more bricks, and each may be dropped into any crate that is not yet full.
Return the largest number of crates that can be filled to the brim.
Example 1
The second crate is already full. Dropping 2 bricks into the first fills it, and the 3 bricks left do not cover the 5 the third crate still needs.
Example 2
Filling the crates needing 1, 2 and 3 bricks uses all six bricks and fills three crates.
Example 3
Every crate is already filled to the brim, so all three count and the delivery is not needed.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def crates_filled(capacity: list[int], rocks: list[int], additionalRocks: int) -> int:public int cratesFilled(int[] capacity, int[] rocks, int additionalRocks)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.