Short javascript solution


  • 0
    D
     * @param {number[]} nums
     * @param {number} val
     * @return {number}
     */
    var removeElement = function(nums, val) {
        var i=0;
        while (i<nums.length) {
            if (nums[i] === val){
                nums.splice(i,1);
                i=-1;
            }
            i++;
        }
        return nums.length;
    };```

Log in to reply
 

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