标签:
https://leetcode.com/problems/remove-element/
1 class Solution { 2 public: 3 int removeElement(vector<int>& nums, int val) { 4 int size=nums.size(); 5 int j=0; 6 for(int i=0;i<size;i++) 7 { 8 if(nums.at(i)!=val) 9 { 10 nums[j]=nums[i]; 11 j++; 12 } 13 } 14 int newSize=j; 15 nums.resize(newSize); 16 return newSize; 17 } 18 };
标签:
原文地址:http://www.cnblogs.com/aguai1992/p/4651414.html