Remove Element
- javascript
- arrays
- in-place
Problem URL:Remove Element
My Solution
JavaScript
/**
* @param {number[]} nums
* @param {number} val
* @return {number}
*/
const removeElement = (nums, val) => {
while (nums.indexOf(val) >= 0) {
nums.splice(nums.indexOf(val), 1);
}
return nums.length;
};
Let's Connect
Twitter •GitHub •LinkedIn