removeDuplicates = function (nums) {
  let swap = 1;

  for (let i = 1; i < nums.length; i++) {
    if (nums[i] != nums[i - 1]) {
      nums[swap] = nums[i];
      swap++;
    }
  }
  return swap;
}
Linear
Time O(N) | Space O(1)
https://leetcode.com/problems/remove-duplicates-from-sorted-array/
@param {number[]} nums
@return {number}