标签:duplicate tor remove 重复 param code move public ret
class Solution {
public:
/**
* @param A: a list of integers
* @return : return an integer
*/
int removeDuplicates(vector<int> &nums) {
// write your code here
if(nums.empty())
{
return 0;
}//if
int n = nums.size(),k=0;
for(int i=1;i<n;++i)
{
if(nums[i] != nums[k])
{
nums[++k] = nums[i];
}//if
}//for
nums.resize(k+1);
return k+1;
}
};
标签:duplicate tor remove 重复 param code move public ret
原文地址:http://www.cnblogs.com/w1500802028/p/6525772.html