Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Deduplicate Events Preserving First Order

Easy
EasyCodingHash Tablesdeduplicationpython
Asked 2mo ago|
Klaviyo
Klaviyo
Asked 1 times

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 Klaviyo

Hi, 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.

Take this as a live interview session →

You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.

Sign up freeI have an account
def solve(rows):
    counts = {}
    for row in rows:
        ...
    return result
Sign up to unlock solutions
Klaviyo AI Engineer Interview QuestionsTop 50 deduplication Interview QuestionsTop 50 python Interview QuestionsKlaviyo Interview Questions
Next questions
MetaDeduplicate Ordered Event StreamMediumProvidenceOptimize Duplicate Event DetectionMediumMetaDeduplicate Meta Event StreamEasy