首页 > 代码库 > Leetcode027. Remove Element

Leetcode027. Remove Element

 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 };

 

Leetcode027. Remove Element