Skip to Main Content

Remove Element

Problem URL:Remove Element

My Solution:

/**
 * @param {number[]} nums
 * @param {number} val
 * @return {number}
 */
var removeElement = function(nums, val) {
    while (nums.indexOf(val) >= 0) {
        nums.splice(nums.indexOf(val), 1);
    }
    return nums.length;
};

Let's Connect

Twitter GitHub LinkedIn