做完上一题后这道题很容易
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
int i=0,j=0;
int number=0;
while(i<nums.size()){
if(nums[i]==val){
i++;
}
else{
nums[j]=nums[i];
i++,j++;
number++;
}
}
return number;
}
};