[LeetCode]Remove Element

题目:给定一个数字集合A。要求去除集合A中全部的elem,并返回新集合A的长度

算法:遍历覆盖

public class Solution {
    public int removeElement(int[] A, int elem) {
	        int length = 0;
	        for (int i=0; i<A.length; ++i) {
	        	if (elem != A[i]) {
	        		A[length++] = A[i];
	        	}
	        }
	        
	        return length;
	    }
}

原文地址:https://www.cnblogs.com/cxchanpin/p/6872743.html