Solve a typical algorithmic challenge, such as finding duplicates in an array.
Implement find_duplicates(nums) to return each distinct duplicated value once, ordered by its second occurrence while scanning from left to right.
Input: A list of integers. Output: A list of integers containing all values that occur at least twice. Return an empty list when no duplicates exist.
def find_duplicates(nums):