Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Finding Duplicates in Records

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

Your question is Finding Duplicates in Records. 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

World Wide Technology data pipelines may receive repeated records during ingestion retries. Given a list of record dictionaries, return the record IDs that appear more than once.

A record is considered a duplicate when its record_id has already appeared earlier in the list. Return each duplicated ID only once, in the order it is first identified as a duplicate.

Formal Specification

Implement find_duplicate_records(records).

  • Input: records, a list of dictionaries. Every dictionary contains an integer record_id and may contain other fields.
  • Output: A list of integer record IDs that occur at least twice.
  • The input list must not be modified.

Constraints

  • 0 <= len(records) <= 100,000
  • Each record contains a valid integer record_id
  • -10^9 <= record_id <= 10^9
  • The input list must not be modified

Function Signature

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