The First of Their Kind
A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- easy
- Seniority
- L3
Problem
An ingestion feed hands you records in arrival order, and the same `key` value can show up more than once whenever an upstream producer retries. Collapse the feed so that for each distinct value of `key`, only the record that arrived first survives, with the survivors left in their original order. Records that carry no `key` field have nothing to collapse against, so pass every one of them through untouched.
Summary
When the same record arrives twice, only the first one survives.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.