Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Duplicate Records Detection

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

Your question is Duplicate Records Detection. 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

OpenTable receives reservation records represented as Python dictionaries. Write a function that identifies records appearing more than once, efficiently.

Two records are duplicates when they contain exactly the same key-value pairs, regardless of dictionary insertion order. Return each duplicated record only once, preserving the order of its first appearance in records.

Formal Specification

Given records, a list of dictionaries whose keys are strings and whose values are hashable primitives such as strings, integers, booleans, or None, return a list of dictionaries. The result must contain one copy of every record that occurs at least twice.

Do not modify the input list or its dictionaries. If no duplicates exist, return an empty list.

Constraints

  • 1 <= len(records) <= 100,000
  • 0 <= len(record) <= 20
  • Every key is a string
  • Every value is hashable
  • Dictionary key order must not affect duplicate detection

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