class Solution {
public int removeElement(int[] nums, int val) {
int ans = nums.length;
int p1 = 0;
for(int p2 = 0; p2 < nums.length; p2++){
if(nums[p2] == val){
ans--;
continue;
}
nums[p1++] = nums[p2];
}
return ans;
}
}
原文:https://www.cnblogs.com/xiafrog/p/14394987.html