Solve a common algorithm problem, such as reversing a string or finding duplicates in an array.
Implement find_duplicates(nums), which returns every value appearing at least twice in nums, listed once in the order it is first detected as a duplicate. Return an empty list when all values are unique. The input is a list of integers, and the output is a list of integers.
def find_duplicates(nums):