Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Finding Duplicates in an Array

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

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

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):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output