27-remove-element

DevGod
Vtuber
class Solution { public int removeElement(int[] nums, int val) { int count=0; for(int i=0;i<nums.length;i++){ if(nums[i]!=val){ nums[count]=nums[i]; count++; } } return count; }}
/** * @param {number[]} nums * @param {number} val * @return {number} */var removeElement = function(nums, val) { let j = 0; for( let n of nums ){ if( n !== val ){ nums[j++] = n; } }
return j;};