As reported: Amazon online assessment (June 2025), question 1 of 2 (the other was Minimizing Vulnerability Factor).
There are n warehouses; warehouse i holds inventory[i] units. Each warehouse is emptied separately by you and a co-worker taking turns, you first: your turn reduces its inventory by dispatch1, the co-worker's by dispatch2, and so on until the inventory is ≤ 0. You earn 1 credit for a warehouse if it is your dispatch that brings it to ≤ 0.
The co-worker can skip a turn, so you dispatch again. Skips are limited to skips in total across all warehouses; one warehouse may use several. Return the maximum number of credits you can earn.
Example 1
inventory = [10,6,12,8,15,1], dispatch1 = 2, dispatch2 = 3, skips = 3
Output: 5
Warehouses 6, 12 and 1 are yours without skips; 8 needs 1 skip; 10 and 15 need 2 each. With 3 skips: 8 (1) and one of 10/15 (2).
Example 2
inventory = [7,7,7], dispatch1 = 5, dispatch2 = 3, skips = 2
Output: 2 each warehouse needs 1 skip
Example 3
inventory = [100,100], dispatch1 = 10, dispatch2 = 90, skips = 0
Output: 0
Constraints: 1 ≤ n ≤ 10⁵; 1 ≤ inventory[i], dispatch1, dispatch2 ≤ 10⁹; 0 ≤ skips ≤ 10⁹.
Code runner format: four lines: inventory as a JSON array, then dispatch1, dispatch2, skips. Implement maxCredits(inventory, dispatch1, dispatch2, skips); the harness prints the result.