27. Remove Element
Remove Element
Solution
public class Solution {
public int removeElement(int[] A, int elem) {
if(A.length < 1) return A.length;
int i = -1;
int j = 0;
while(j < A.length){
if(A[j] != elem){
A[++i] = A[j];
}
j ++;
}
return i+1;
}
}Last updated