LeetCode 26. Remove Duplicates from Sorted Array
2022.07.18
問題
typescript
typescriptfunction removeDuplicates(nums: number[]): number { const len = nums.length for (let i = 0; i < len - 1; i++) { if (i > nums.length -1) { break } if (nums[i] === nums[i+1]) { nums.splice(i, 1) i-- } } return nums.length };