简单题,发现对Array掌握的还不错啊。
public int removeDuplicates(int[] A) {
int index = 0;
for (int i = 0; i < A.length; i++){
if (i== 0 || (i >0 && A[i] != A[i - 1])) {
A[index] = A[i];
index++;
} else {
continue;
}
}
return index;
}
No comments:
Post a Comment