Share my JavaScript code


  • 0
    F

    for(var i=0;i<nums.length;i++){
    for(var ii=i+1,duplicates=false;ii<nums.length;duplicates?ii:ii++){
    duplicates=false;
    if(nums[i]>nums[ii]){
    var middle = nums[i];
    nums[i] = nums[ii];
    nums[ii] = middle;
    }else if(nums[i]===nums[ii]){
    nums.splice(ii,1);
    duplicates=true;
    }
    }
    }
    return nums


Log in to reply
 

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