My JavaScript Solution


  • 0
    S
    var removeDuplicates = function(nums) {
        var l = nums.length - 1,
        	i = 1;
        while (i <= l) {
            if (nums[i] == nums[i - 1]) {
                nums.splice(i, 1);
                l--;
            } else {
                i++;
            }
        }
        return nums.length
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.