```
class Solution:
# @param A a list of integers
# @param elem an integer, value need to be removed
# @return an integer
def removeElement(self, A, elem):
if not A:
return 0
n = 0
for i in range(len(A)):
if A[i] != elem:
A[n] = A[i]
n += 1
return n
```