My Javascript Solution


  • 0
    R
    var removeElement = function(nums, val) {
        //Go through the array and delete occurences of that value
        for(var i = 0; i < nums.length; i++){
            if(nums[i] === val){
                nums.splice(i,1);
                i--;
            }  
        };
        //Return the new length
        return nums.length;
    };

Log in to reply
 

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