Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find Duplicate Event ID

Easy
EasyCodingHash TablesArraysAsked 1 times

Problem

In an Alten Nederland mobile app telemetry pipeline, event IDs should be unique within a single upload batch. Given a list of integers event_ids, return the first value that appears more than once when scanning from left to right. If no duplicate exists, return -1.

Formal Specification

  • Input: event_ids, a list of integers
  • Output: An integer representing the first duplicated value encountered during a left-to-right scan, or -1 if all values are unique

A value is considered the first duplicate if its second occurrence appears before the second occurrence of any other duplicated value.

Constraints

  • 1 <= len(event_ids) <= 10^5
  • -10^9 <= event_ids[i] <= 10^9
  • Return the value whose second occurrence appears first
  • If no duplicate exists, return -1

Function Signature

def first_duplicate(event_ids):
Practicing as: Mobile Engineer interview at Alten Nederland

Hi, I'll play your Alten Nederland interviewer for the Mobile Engineer role. Answer the question above like we're in the room, and I'll respond the way a real interviewer would.

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
Alten Nederland Mobile Engineer Interview Questions
Next questions
ProvidenceOptimize Duplicate Event DetectionMediumKlaviyoDeduplicate Events Preserving First OrderEasyOptimize Duplicate Detection in ArraysEasy