func removeDuplicates(nums []int) int {
i := 0
for j:=0; j<len(nums); j++ {
if nums[i] != nums[j] {
i++
nums[i] = nums[j]
}
}
return i+1
}
public class Solution {
/*
* @param nums: An ineger array
* @return: An integer
*/
public int removeDuplicates(int[] nums) {
if (nums == null || nums.length == 0)
return 0;
int i = 0;
for (int j = 0; j < nums.length; j++) {
if (nums[i] != nums[j]) {
i++;
nums[i] = nums[j];
}
}
return i + 1;
}
}