Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Finding Duplicates in an Array
00:00
5 left

Finding Duplicates in an Array

MediumPython

Problem

How would you find duplicates in an array?

Return a list containing each value that appears at least twice, included only once. Implement def find_duplicates(nums):, where nums is a list of integers and the result preserves the order in which values are first detected as duplicates.

Constraints

  • 0 <= nums.length <= 10000
  • -1000000000 <= nums[i] <= 1000000000
  • Return each duplicated value exactly once
  • Preserve duplicate-detection order

Function Signature

def find_duplicates(nums):
Interviewer

Your question is Finding Duplicates in an Array. Start with the requirements in the Question tab.

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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.