본문 바로가기
Coding Test/LeetCode

[LeetCode] (Array) Lv Easy. Remove Duplicates from Sorted Array

by song.ift 2023. 1. 14.

https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/727/

 

Explore - LeetCode

LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore.

leetcode.com

 

/**
 * @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

 

GitHub - developeSHG/Algorithm-LeetCode: 릿코드 소스코드

릿코드 소스코드. Contribute to developeSHG/Algorithm-LeetCode development by creating an account on GitHub.

github.com

 

댓글