Remove Global Duplicates While Preserving Order
Company: Vanta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Overview: Practice removing duplicate strings globally while preserving first-seen order and leaving the input unchanged. Consider how the design changes when the input is too large to fit in memory.
Constraints
- 0 <= len(values) <= 200,000
- Every element is a string.
- String comparison is case-sensitive.
Examples
Input: ([],)
Expected Output: []
Explanation: Covers first-occurrence retention and stable order.
Input: (['a'],)
Expected Output: ['a']
Explanation: Covers first-occurrence retention and stable order.
Hints
- Track values already retained in a hash set.
- Append a value only when it is first inserted into the set.
- Discussion only: a partitioned external-memory design must preserve the global first position of every value before its ordered emit phase.