solution.cpp 269 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
	int removeElement(vector<int> &nums, int val)
	{
		int count = 0;
		for (int i = 0; i < nums.size(); i++)
		{
			if (nums[i] != val)
			{
				nums[count++] = nums[i];
			}
		}
		return count;
	}
};