错误代码
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
int count=0;
vector<int>::iterator it;
if((nums.begin()==nums.end())&&(*nums.begin()==val))
nums.erase(nums.end());
else if(nums.size()==0) return 0;
else
{
for( it = nums.begin(); it != nums.end(); it++ )
{
if(val==*it)
{
count++;
nums.erase(it);
it--;
}
}
}
return count;
}
};