public int removeElement(int[] A, int elem) {
int oldLength = A.length;
int newLength = oldLength;
for (int i = 0;i<oldLength;i++) {
if (A[i] == elem)
newLength;
}
return newLength;
}
Can anyone tell me what this problem means

You should count the newLength, and also make the first newLength elements in the array are the values which do not need to be removed.
For example,
A=[0,2,3,2,5] elem=2
, you should return3
and also make the original A array like[0,3,5,2,2]
. However, the problem description has announced that order is ok, so your A might be[5,0,3,2,2]
or whatever.

"remove all instances of that value in place and return the new length". notice that you should remove the elem in int[] A but not only count and calculate the newLength. in your code, you keep the original array A[], not changing it to a new array
public int removeElement(int[] A, int elem) { int count = 0; for (int i = 0; i < A.length; ++i) { if (A[i] == elem) { ++count; } else if(count > 0) { A[i  count] = A[i]; } } return A.length  count; }
this is my method, in the
else
statement, replace the element inA[]
with the element after it.

Use a variable to store the boundary between two sets of elements. No extra of copy operation is needed.
class Solution { public: int removeElement(int A[], int n, int elem) { int boundary = n; for (int i = 0; i < boundary; ++i) { if (A[i] == elem) { while (boundary > i && A[boundary] == elem) ; if (boundary == i) return boundary; else std::swap(A[i], A[boundary]); } } return boundary; } };

Thanks for your sharing.
However, answers you've written must describe your code with more detail content. Please read the FAQ (http://oj.leetcode.com/discuss/faq) for more info.

traverse the array, when we found A[i]==elem, assign the last number of array(A[length1]) to A[i], then i,length, so at last length will be the answer
int removeElement(int A[], int n, int elem) { int length = n; for(int i=0; i<length; i++) { if(elem == A[i]) { A[i] = A[length1]; length; i; } } return length; }

Hi @wbqhust, appreciate your answer. Even though your solution is super elegant, it would be better to word your idea.