Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Deduplicate Events Preserving First Order

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Deduplicate Events Preserving First Order. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Given a list of customer event IDs events in arrival order, return a new list containing only the first occurrence of each event ID. If the same ID appears again later as a late-arriving duplicate, it should be ignored. The output must preserve the order of the first time each distinct event ID appeared.

Constraints

  • 0 <= len(events) <= 10^5
  • Each event ID is hashable and can be compared for equality
  • Preserve the order of first occurrence exactly

Function Signature

def deduplicate_events(events):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output