public class Solution {
/**
* @param A: a array of integers
* @return : return an integer
*/
public static int removeDuplicates(int[] nums) {
int a = 1;
int l = nums.length;
if(l == 0)
return 0;
else if(l == 1)
return 1;
else{
for(int i=1;i<l;i++)
{
if(nums[i]!=nums[a-1])
{
nums[a++] = nums[i];
}
}
return a;
}
}
}
时间: 2025-01-17 13:29:04