Your question is Find Duplicate Elements Efficiently. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given an array of integers, how would you find the duplicate elements efficiently?
Implement find_duplicates(nums) to return each value that appears at least twice, exactly once, in the order it is first identified as a duplicate. The input is a list of integers, and the output is a list of integers. For example, [4, 3, 2, 7, 8, 2, 3, 1] returns [2, 3]; [1, 1, 2, 2, 3] returns [1, 2].
def find_duplicates(nums):