[Link] https://leetcode.com/problems/remove-element/
1
2
3
4
5
6
7
8
9
10
class Solution {
public int removeElement(int[] nums, int val) {
int updateIdx = 0;
for(int e: nums) {
if(e == val) continue;
nums[updateIdx++] = e;
}
return updateIdx;
}
}