int removeDuplicates(vector<int>& nums) {
int n = nums.size();
if (n == 0)
return 0;
//indicates how many elements we skip
int count = 0;
for (int i = 0; i < n  1; i++) {
if (nums[i] == nums[i + 1])
count++;
else if (count != 0)
nums[i  count] = nums[i];
}
nums[n  1  count] = nums[n  1];
return n  count;
}
My O(n) C++ solution.


I think you should check differences between them(arrays vs vectors) and then you'll find the answer =)
http://stackoverflow.com/questions/15079057/arraysvsvectorsintroductorysimilaritiesanddifferences