Find duplicate elements from an array.
Implement find_duplicates(nums) to return every value that appears at least twice, exactly once, ordered by the index where its duplicate is first detected. The input is a list of integers, and the output is a list of integers. Return an empty list when no value is duplicated.
def find_duplicates(nums):