Leetcode 27 Remove Element STL
和remove zero类似的方法完成该题
1 class Solution { 2 public: 3 int removeElement(vector<int>& nums, int val) { 4 vector<int>::size_type j = 0; 5 for(vector<int>::size_type i = 0; i < nums.size(); ++i){ 6 if(nums[i] != val) nums[j++] = nums[i]; 7 } 8 return j; 9 } 10 };