[LintCode] Remove Element

public int removeElement(int[] A, int elem) {
        // write your code here
        int res = 0;
        if(A.length == 0 || A == null)
            return res;
        for(int i = 0 ; i < A.length; i++) {
            if(A[i] != elem)
                A[res++] = A[i];
        }
        return res;
    }