1 //water 2 class Solution { 3 public: 4 int removeElement(vector<int>& nums, int val) { 5 for(vector<int>::iterator it=nums.begin();it!=nums.end();) 6 { 7 if(*it == val)nums.erase(it); 8 else it++; 9 } 10 return nums.size(); 11 } 12 };
时间: 2024-11-18 04:52:02