class Solution(object):
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
slow = fast = 0
while (fast < len(nums)):
if nums[fast] != val:
nums[slow] = nums[fast]
slow = slow+1
fast = fast + 1
return slow
相关题目推荐
26.删除排序数组中的重复项
283.移动零
844.比较含退格的字符串
977.有序数组的平方