标签:
题目:
Given an array and a value, remove all instances of that value in place and return the new length.
The order of elements can be changed. It doesn‘t matter what you leave beyond the new length.
这个比较简单,掌握vector的用法即可。
1 int removeElement(vector<int>& nums, int val) { 2 vector<int>::iterator it; 3 for(it=nums.begin();it!=nums.end();) 4 { 5 if(val==*it) 6 it = nums.erase(it); 7 else 8 it++; 9 } 10 return nums.size(); 11 }
leetcode第27题:删除vector数组的元素(array)
标签:
原文地址:http://www.cnblogs.com/WonderHow/p/4584489.html