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):
Practicing as: AI Engineer interview at KlaviyoHi, I'll play your Klaviyo interviewer for the AI Engineer role. Candidates describe these interviews as often stressful and moderately difficult, so expect me to be direct and to the point. Take your time with the question above and answer like we're in the room.
You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.


