Write a program which finds the non-unique elements of an array of signed integers. The resulting array can be in any order.
Your answer may be a snippet which assumes the input to be stored in a variable (d
, say) and evaluates to the correct result.
Test Cases
Each test case is a single line in the format input => output
. Note that other permutations of the output are valid as well.
[] => []
[-1, 0, 1] => []
[1, 1] => [1]
[3, 0, 0, 1, 1, 0, 5, 3] => [3, 0, 1]
[-34, 0, 1, -34, 4, 8, 4] => [-34, 4]
Order of the elements doesn't matter.
This is code golf, so the shortest answer (in bytes) wins.
[-1, 0, 1]
, can we input (replace \n with newlines):"-1\n0\n1"
? \$\endgroup\$