Problems178
Search for a command to run...
Try your own input
Change the array and replay the algorithm from step one.
Current step
Remove all occurrences of val = 3 from the array in-place. Return new length.
Two Pointers
1function removeElement(nums, val) {//n: 4val: 3i: —k: 02 let k = 0;3 for (let i = 0; i < nums.length; i++) {4 if (nums[i] !== val) {5 nums[k] = nums[i];6 k++;7 }8 }9 return k;10}