Given an array of integers, write a function to remove all duplicates without using extra space.
Implement remove_duplicates(nums) so it mutates nums, keeps the first occurrence of each value, preserves the original order of retained values, and returns the modified array. The function may use only constant auxiliary space.
nums is a list of integers. Return the same list after removing duplicates.
def remove_duplicates(nums):