class Solution { public: int removeDuplicates(vector<int> &nums) { if(nums.empty()) { return 0; } int n = nums.size(),k=0; for(int i=1;i<n;++i) { if(nums[i] != nums[k]) { nums[++k] = nums[i]; } } nums.resize(k+1); return k+1; } };
posted on 2017-03-08 20:14 Youmeme 阅读(73) 评论(0) 编辑 收藏 举报
Powered by: 博客园 Copyright © 2024 Youmeme Powered by .NET 9.0 on Kubernetes