```
public static int removeDuplicates(int[] nums) {
if (nums.length <= 1)
return nums.length;
int turtle = 0;
int max = nums[0];
int rabbit = 0;
while (rabbit < nums.length&&turtle<=nums.length-1) {
while (rabbit < nums.length && nums[rabbit] <= max)
rabbit++;
turtle++;
if (rabbit < nums.length&&turtle<nums.length) {
max = nums[rabbit];
swap(nums, turtle, rabbit);
}
}
return turtle;
}
```