Write a function to reverse a string or find duplicate elements in an array using your preferred programming language.
For this exercise, implement the duplicate-elements option. Given an array of integers, return each value that appears more than once, exactly once, in the order its second occurrence is encountered.
Input: A list of integers. Output: A list containing the duplicate values. Return an empty list when no value is duplicated.
def find_duplicates(nums):