DE Shaw 校园面

Question
Given an array of size n containing numbers in the range of long data type, find out all the duplicates in the array.

Sample Input 0
[2, 3011, 4, 2, 1, 5, 3011, 8000]
Output should be 2 and 3011.

Is it possible to find the frequency of repeating elements? How if possible?

Expected time - O(n)
Expected space - O(1)

类似 https://leetcode.com/problems/find-all-duplicates-in-an-array/