with [1,1] as input, the following code has run-time error, but why...

```
class Solution {
public:
int removeDuplicates(vector<int>& nums) {
int size = nums.size();
if(size <= 1) return size;
int target = nums[size-1];
int length = size;
for(size_t i = size-2; i >= 0; i--) {
if(nums[i] == target) {
length--;
for(size_t j = i+1; j < size; j++) {
nums[j-1] = nums[j];
}
}
else {
target = nums[i];
}
}
return length;
}
};
```