public int removeElement(int[] A, int elem) {
// Start typing your Java solution below
// DO NOT write main() function
int length = A.length;
int count = 0;
int i = 0;
while(i < length - count){
if(A[i] == elem){
count++;
for(int j = i; j < length - 1; j++){
A[j] = A[j + 1];
}
continue;
}
i++;
}
return length - count;
}
Remove Element
最新推荐文章于 2021-02-10 01:24:19 发布