Write a program to find duplicate elements in an array or list in O(n) time complexity.
Implement find_duplicates(nums), where nums is a list of integers. Return a list containing each duplicated value exactly once, ordered by the point at which it is detected. The input list may be empty, and values may be positive, zero, or negative.
def find_duplicates(nums):