Javascript solution (Beats 99%)


  • 1
    R
    var removeDuplicates = function(nums) {
        var firstP = 0,
            secondP = 0;
        
        while(secondP < nums.length){
            if(nums[secondP] > nums[firstP]){
                firstP++;
                nums[firstP] = nums[secondP];
            }
            secondP++;
        }
        
        return firstP + 1;
        
    };

Log in to reply
 

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