Problem, as an interviewer would state it:
"Implement findDuplicates(arr) — returning every element that appears MORE THAN ONCE in the array, with each duplicate value appearing exactly ONCE in the output."
Examples:
findDuplicates([1,2,3,2,4,3,3]); // [2,3]
Clarifying questions expected:
- Should each duplicate VALUE appear exactly once in the output, regardless of how many total times it repeated in the input?
- What real, correct order should the duplicate values themselves appear in — their own first-occurrence order, or any order?
- Does this need to also report HOW MANY times each duplicate appeared, or just identify which values are duplicated?
Code / implementation expected: Yes — real, direct proof of correct duplicate detection, confirmation an already-unique array correctly produces an empty result, and confirmation of the output's own real order.