Write a code to Find duplicate numbers in an array
Asked in the technical interview stage. Candidate directly gave the optimal approach.
Implement def find_duplicates(nums):. Return each value that appears at least twice, exactly once, ordered by the position where its second occurrence is encountered.
Example 1: [4, 3, 4, 2, 3, 4] returns [4, 3].
Example 2: [1, 2, 3] returns [].
nums contains 0 to 10,000 integers, each between -10^9 and 10^9.
def find_duplicates(nums):