基础解法,必须掌握!!!
class Solution {
public int removeDuplicates(int[] nums) {
if (nums.length < 2) {
return nums.length;
}
int slow = 0, fast = 1;
while (fast < nums.length) {
if (nums[fast] > nums[slow]) {
nums[++slow] = nums[fast++];
} else {
fast++;
}
}
return slow + 1;
}
}