How would you find duplicates in an array?
Return a list containing each value that appears at least twice, included only once. Implement def find_duplicates(nums):, where nums is a list of integers and the result preserves the order in which values are first detected as duplicates.
def find_duplicates(nums):