Which products repeat?

hashing

Which products repeat?

Wayfair Python Interview Question

Wayfair's catalog team found that some product SKUs were loaded more than once during an import.

Write a function find_duplicates(skus) that returns every SKU that appears more than once, listed once each and sorted from smallest to largest.

Asked of

  • Data Analyst
  • Data Engineer
  • Data Scientist
  • ML Engineer
  • AI Engineer

Example 1

Input

skus = [4, 3, 2, 7, 8, 2, 3, 1, 2]

Output

[2, 3]

Example 2

Input

skus = [1, 2, 3]

Output

[]

Explanation

In the first example, SKU 3 appears twice and SKU 2 appears three times, so the answer is [2, 3]. SKU 2 is listed once even though it repeats more than once.

Submit also runs 3 hidden test cases that check edge cases.