Zero the stock counts of recalled pallet slots
Your task
A supplier has recalled some pallets, so the warehouse must stop picking from their slots. The stock system holds one unit count per slot, and the recall arrives as a list of slot positions.
Write zero_recalled(counts, recalled) that returns the counts after the recall.
Input and output:
counts: a list of up to 100,000 unit counts, each an integer between 0 and 1,000,000. The slot at positionihas countcounts[i], with positions counted from 0. It may be empty.recalled: a list of up to 100,000 slot positions. Each one is a position that exists incounts. It may be empty.- Returns a list of integers, one per slot, in slot order.
Rules:
- Every slot whose position appears in
recalledhas a count of 0 in the result. - Every other slot keeps its count.
- A position can appear in
recalledmore than once. - You may change
countsin place and return it, or return a new list.
Examples
zero_recalled(counts: list[int], recalled: list[int]) -> list[int]Example 1
Input
zero_recalled([5, 3, 8], [0, 2])Output
[0, 3, 0]Example 2
Input
zero_recalled([4, 4, 4, 4], [1, 1, 3])Output
[4, 0, 4, 0]Example 3
Input
zero_recalled([2, 7], [])Output
[2, 7]