← All problemsExample 1 Example 2 Example 3
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.
- 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.
- Input
arr = [4, 4, 4, 5]- Output
[4]- Explanation
4 appears three times but is listed only once.
- Input
arr = [1, 2, 3]- Output
[]- Explanation
nothing repeats, so the result is empty.
Tab indents. Press Esc, then Tab to leave the editor.
Ctrl or ⌘ + Enter runs the tests.
Run your code to see every test here. Nothing is submitted or recorded.