Write a function to remove duplicates from an array.
Return a new array containing each value once, preserving the order of its first occurrence. The input is an array of integers, and the original array must not be modified.
Function signature: def remove_duplicates(nums):
Example: [3, 1, 3, 2, 1] returns [3, 1, 2]. An empty array returns an empty array.
Constraints: 0 <= len(nums) <= 10^4, and each value is an integer.
def remove_duplicates(nums):