public class Solution {
public int removeDuplicates(int[] nums) {
if (nums.length <= 1) {
return nums.length;
}
int cnt = 0;
for (int i = 1; i < nums.length; i++) {
if (nums[cnt] != nums[i]) {
nums[++cnt] = nums[i];
}
}
return cnt + 1;
}
}