巩长胜

导航

删除排序数组中的重复数字

public static int removeDuplicates(int[] A) {
int len = A.length;
if (len == 0)
return 0;
int count = 1;
for (int i = 1; i < len; i++) {
if (A[i] == A[i - 1]) {
continue;
}else{
A[count] = A[i];
count++;
}
}
return count;
}

posted on 2017-03-08 20:03  苏莫  阅读(71)  评论(0编辑  收藏  举报