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 len(A):
length=len(A)
count=0
for num in A:
if num==elem:
count=count+1
while count>0:
A.remove(elem)
length-=1
count=count-1
return length
else:
return 0
Python学习——leetcode(Remove Element)
最新推荐文章于 2019-09-23 20:23:00 发布