https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/727/
/**
* @param {number[]} nums
* @return {number}
*/
var removeDuplicates = function(nums) {
for (let i = nums.length - 1; i > 0; i--) {
if (nums[i] === nums[i - 1]) nums.splice(i, 1);
}
return nums.length;
};
GitHub : https://github.com/developeSHG/Algorithm-LeetCode/tree/main/remove-duplicates-from-sorted-array
'Coding Test > LeetCode' 카테고리의 다른 글
[LeetCode] (Trees) Lv Easy. Maximum Depth of Binary Tree (0) | 2023.01.21 |
---|---|
[LeetCode] (Linked List) Lv Easy. Delete Node in a Linked List (0) | 2023.01.16 |
[LeetCode] (Strings) Lv Easy. Reverse Integer (0) | 2023.01.16 |
[LeetCode] (Array) Lv Easy. Best Time to Buy and Sell Stock II (0) | 2023.01.16 |
[LeetCode] (Array) Lv Easy. Find Target Indices After Sorting Array (0) | 2023.01.12 |
댓글