```
public int removeDuplicates(int[] nums) {
int count = 0;
int p1 = Integer.MAX_VALUE, p2 = Integer.MAX_VALUE;
for(int i = 0; i < nums.length; i++) {
if(p1 == p2 && p2 == nums[i]) {
// i++;
} else {
p1 = p2;
p2 = nums[i];
nums[count++] = nums[i];
}
}
return count;
}
```