Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Detect Duplicates in Player List

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

Your question is Detect Duplicates in Player List. 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

FanDuel contest data may contain the same player more than once because of duplicated feed records or invalid lineup construction. Given a list of player records, return every duplicated player_id exactly once, ordered by the position where that ID is first detected as a duplicate.

Formal Specification

Implement find_duplicate_players(players), where players is a list of dictionaries. Each dictionary contains a hashable player_id, represented as an integer or string. Return a list of player IDs that occur at least twice. Each duplicate ID must appear once in the output.

A player ID is added to the result when its second occurrence is encountered. Do not mutate players.

Constraints

  • 0 <= len(players) <= 10^5
  • Every record contains exactly one player_id key
  • Each player_id is an integer or string and is hashable
  • Preserve input order and do not modify the input list

Function Signature

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