Code Room
CodingEasy
Question
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.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.