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就更好了。

原文地址:https://www.cnblogs.com/gattaca/p/4499869.html