Stock replenishment

Write codeEasy10 min

Your task

A warehouse wants every product topped up to a minimum stock level. Given the current count of each product and the target level, return the total number of units to order: for each product below the target, add (target minus its count); products at or above the target need nothing. Example: counts [3, 7, 2] with target 5 needs 2 + 0 + 3 = 5 units.

Examples

restock_units(counts: list[int], target: int) -> int
Example 1
Inputrestock_units([3, 7, 2], 5)
Output5