Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Duplicate Entries Function

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

Your question is Duplicate Entries Function. 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

During QA validation of the Oakley Prizm catalog, each imported product identifier should appear only once. Given a list of catalog IDs, determine whether any identifier occurs more than once.

Return True if at least one duplicate exists. Return False when every identifier is unique.

Formal Specification

Implement contains_duplicate(entries), where entries is a list of strings. The function must return a boolean and must compare identifiers using exact, case-sensitive string equality. An empty list contains no duplicates.

Constraints

  • 0 <= len(entries) <= 100,000
  • Each identifier is a non-empty string of at most 64 characters
  • Identifier comparisons are case-sensitive

Function Signature

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