标签:
1 class Solution { 2 public: 3 int removeDuplicates(vector<int>& nums) { 4 if (nums.size() < 3) return nums.size(); 5 else { 6 int i = 2, j = 1; 7 while (i < nums.size()) { 8 if (nums[i] != nums[j - 1]) { 9 nums[++j] = nums[i]; 10 } 11 ++i; 12 } 13 return j + 1; 14 } 15 } 16 };
080. Remove Duplicates from Sorted Array II
标签:
原文地址:http://www.cnblogs.com/shadowwalker9/p/5899609.html