标签:
class Solution { public: int removeDuplicates(vector<int>& nums) { vector<int>new_nums; int s = nums.size(); int len=0; for(int i=0;i<s;){ //注意:1,不能写c++ 2,i<s,而不是nums[i] int temp = nums[i]; i++; len++; new_nums.push_back(nums[i-1]); while(nums[i] == temp){ i++; } } nums.clear(); nums = new_nums; return len; } };
Remove Duplicates from Sorted Array
标签:
原文地址:http://www.cnblogs.com/julie-yang/p/4696585.html