题目链接
双指针思想,和上一篇Leetcode27类似
class Solution {
public int removeDuplicates(int[] nums) {
int slow = 0;
for(int fast = 1; fast < nums.length; fast++){
if(nums[fast] != nums[slow]){
nums[++slow] = nums[fast];
}
}
return slow + 1;
}
}