K04
Missing Product Codes
Problem Statement & Objective
In a warehouse management system, item SKUs are sequentially numbered from 1 to n without gaps. During the night shift count, items were scanned and stored in an UNSORTED list. The warehouse manager needs to know which product codes were missed.
Given integer n and the list of scanned codes, return the MISSING codes as an ASCENDING sorted list.
Function Signature (Python)
missing_product_codes(n: int, scanned: list[int]) -> list[int]Input & Output Contract
Output Rule:List of missing codes in ascending order. If no codes are missing, returns empty list [].
System Constraints
1 <= n <= 10^6
gelenler contains UNIQUE values in the range 1..n
gelenler.length <= nExample Execution Walkthrough
n = 7, gelenler = [2, 4, 1, 7, 5]
expected set: {1,2,3,4,5,6,7}; scanned set: {1,2,4,5,7}
missing: 3 and 6 -> result [3, 6]Example Test Scenarios (3)
Example 1
Input:
[7,[2,4,1,7,5]]Expected Output:
[3,6]Example 2: Missing Evens
Input:
[5,[1,3,5]]Expected Output:
[2,4]Example 3: Missing Boundary (1 ve 4)
Input:
[4,[2,3]]Expected Output:
[1,4]