Stock replenishment
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.
Implement
restock_units(counts: list[int], target: int) → intExamples
in
[[3,7,2],5]out5What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 10 min
solution.py
InputExpectedGot
[[3,7,2],5]5not run yetsample