Given a set of data, how would you find duplicates efficiently?
Implement find_duplicates(nums), where nums is a list of integers. Return a list containing each value that appears at least twice, exactly once, in the order its second occurrence is encountered. Return an empty list when all values are unique.
Input: A list of integers. Output: A list of duplicate integers.
def find_duplicates(nums):