dedupe_preserve_order(items) that returns a new list with duplicate values removed, keeping only the first occurrence of each value and preserving the original order. Do not use set() directly on the output (since sets don't preserve order) — track what has been seen instead.items = [3, 1, 3, 2, 1, 4]
[3, 1, 2, 4]
Each value is kept only the first time it appears.
Keep a set of values already seen while building the result list.
Skip an item if it is already in the seen set; otherwise add it to both the result and the seen set.