Remove Element

题目描述:

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.

 

solution:

int removeElement(vector<int>& nums, int val) {
    return remove(nums.begin(), nums.end(), val) - nums.begin();
}

  如果有时间的话,自己实现remove就更好了。

posted @ 2015-05-13 11:11  Sawyer Ford  阅读(117)  评论(0编辑  收藏  举报