#include <bits/stdc++.h>
using namespace std;
int removeDuplicates(vector<int>& nums) {
int numsSize = nums.size();
if(numsSize <= 1)
return numsSize;
int j = 1;
for(int i = 1; i < numsSize; i++){
if(nums[i] != nums[i - 1]){
nums[j++] = nums[i];
}
}
return j;
}
int main() {
vector<int> nums(4);
nums[0] = 2;
nums[1] = 2;
nums[2] = 3;
nums[3] = 3;
int x = removeDuplicates(nums);
for(int i = 0 ; i < x; i++){
cout << nums[i] << " " ;
}
cout << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgcmVtb3ZlRHVwbGljYXRlcyh2ZWN0b3I8aW50PiYgbnVtcykgewogICAgaW50IG51bXNTaXplID0gbnVtcy5zaXplKCk7CiAgICBpZihudW1zU2l6ZSA8PSAxKQogICAgICAgIHJldHVybiBudW1zU2l6ZTsKCiAgICBpbnQgaiA9IDE7Cglmb3IoaW50IGkgPSAxOyBpIDwgbnVtc1NpemU7IGkrKyl7CiAgICAgICAgaWYobnVtc1tpXSAhPSBudW1zW2kgLSAxXSl7CiAgICAgICAgICAgIG51bXNbaisrXSA9IG51bXNbaV07CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIGo7Cn0KCmludCBtYWluKCkgewoJdmVjdG9yPGludD4gbnVtcyg0KTsKCW51bXNbMF0gPSAyOwoJbnVtc1sxXSA9IDI7CgludW1zWzJdID0gMzsKCW51bXNbM10gPSAzOwoJaW50IHggPSByZW1vdmVEdXBsaWNhdGVzKG51bXMpOwoJZm9yKGludCBpID0gMCA7IGkgPCB4OyBpKyspewoJCWNvdXQgPDwgbnVtc1tpXSA8PCAiICIgOwogCX0KIAljb3V0IDw8IGVuZGw7CglyZXR1cm4gMDsKfQ==