Last active
January 11, 2021 09:21
-
-
Save pitsanujiw/3e6bd4b3228faae17ae3358f398a9783 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function removeDuplicates(nums: number[]): number[] { | |
if (nums.length === 0) return []; | |
let i=0; | |
nums.sort(); | |
for (let j =1; j < nums.length; j++) { | |
if (nums[j] != nums[i]) { | |
i++; | |
nums[i] = nums[j]; | |
} | |
} | |
return nums; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment