public int removeElement(int[] A, int elem) {
		int n = A.length;
		if (n == 0)
			return 0;
		else if (n == 1 & A[0] != elem)
			return 1;
		else if (n == 1 & A[0] == elem)
			return 0;
		else {
			int i = 0, j = n - 1;
			while (i <= j) {
				if (A[i] == elem) {
					exchange(A, i, j);
					j--;
				} else {
					i++;
				}
			}
			return i;
		}
	}