Problem
In a Meta event pipeline, duplicate records may arrive for the same event ID. Write a function that removes duplicates by event_id, keeping only the event with the largest timestamp for each ID.
Return the deduplicated events sorted by timestamp ascending. If two events have the same event_id and the same timestamp, keep the one that appears later in the input.
Constraints
- 0 <= len(events) <= 10^5
- event_id is a non-empty string
- 0 <= timestamp <= 10^9
- Each event contains keys: event_id, timestamp, payload
Function Signature
def deduplicate_events(events):
Practicing as: Data Engineer interview at MetaHi, I'll play your Meta interviewer for the Data Engineer role. Candidates describe these interviews as mostly positive and moderately difficult, so expect me to be friendly and conversational. 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.


