Remove Duplicate Integers While Preserving Order
Company: Upstart
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Take-home Project
Quick Answer: Remove duplicate integers while preserving the order of their first appearances. Use a membership set alongside a separate output list for linear expected time, retain the first copy, return a new list, and handle up to one million values.
Constraints
- 0 <= len(values) <= 1000000
- Values fit signed 64-bit integers
- Return a new list without mutating values
Examples
Input: []
Expected Output: []
Explanation: Empty input stays empty.
Input: [3, 5, 5, 7, 8, 8, 9]
Expected Output: [3, 5, 7, 8, 9]
Explanation: The first occurrence order is preserved.
Hints
- Use one structure for membership and another for ordered output.
- Append only when a value has not been seen.