Skip to main content
CodeOath
← All problems

Problem

Find All Duplicates

Easy
  • arrays
  • hash-table

Return every value that shows up more than once in arr. List each such value one time. The order of the result does not matter.

Example 1
Input
arr = [1, 2, 3, 2, 1]
Output
[1, 2]
Explanation

1 and 2 each appear twice. 3 appears once, so it is left out.

Example 2
Input
arr = [4, 4, 4, 5]
Output
[4]
Explanation

4 appears three times but is listed only once.

Example 3
Input
arr = [1, 2, 3]
Output
[]
Explanation

nothing repeats, so the result is empty.

Tab indents. Press Esc, then Tab to leave the editor.

Run your code to see every test here. Nothing is submitted or recorded.