Topic describes

export function removeDuplicates(nums: number[]) :number {
  
  // while (i < len && nums[i] ! == undefined) {
  // Since the array is in ascending order, compare the current value to the next value. The next value is equal to the current value and remove it from the array
  // if (nums[i + 1] === nums[i]) {
  // nums.splice(i + 1, 1);
  // } else {
  // If the next value is greater than the current value, a new round of comparisons begins with the next value
  // i += 1;
  / /}
  // }
  // return nums.length;

  //🧍‍♂️... Is too strong
  let fast = 1;
  let slow = 0;
  while (fast < nums.length) {
    if (nums[fast] > nums[slow]) nums[++slow] = nums[fast];
    fast++;
  }
  return ++slow;
}
Copy the code