Problem Brief
Max Batches For Shipment
OA
There are n unique categories of goods. You are given an array inventory of length n, where inventory[i] denotes the count of items available for category i (with i ranging from 0 to n - 1). These goods need to be organized into groups for delivery.
Group Packing Conditions:
Goal:
1Example 1
Input
inventory = [2, 3, 1, 4, 2]
Output
4
Explanation
The initial bundle holds 1 unit from type 4. Leftover stock: [2, 3, 1, 4, 1]
The second bundle packs 2 units from types 0 and 1. Remaining stock: [1, 2, 1, 4, 1]
The third bundle consists of 3 units from types 0, 1, and 3. Remaining stock: [0, 1, 3, 1]
The fourth bundle carries 4 units from types 1, 2, 3, and 4. Remaining stock: [0, 0, 0, 2, 0]
So we get 4 as our expected output :)