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