// Source : https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/
// Author : Tianming Cao
// Date : 2018-02-02
package removeDuplicatesFromSortedArray;
public class RemoveDuplicatesFromSortedArray {
public int removeDuplicates(int[] nums) {
if (nums == null || nums.length == 0) {
return 0;
}
int n = nums.length;
int len = 0;
for (int i = 1; i < n; i++) {
if (nums[i] != nums[len]) {
nums[len + 1] = nums[i];
len++;
}
}
return len + 1;
}
}