class Solution:
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
ptr = 0
while ptr < len(nums):
if nums[ptr] == val:
del nums[ptr]
else:
ptr += 1
return len(nums)
class Solution:
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
ptr_val = 0
ptr_tmp = 0
while ptr_tmp < len(nums):
if nums[ptr_tmp] == val:
nums[ptr_tmp] = nums[ptr_val]
ptr_val += 1
ptr_tmp += 1
del nums[0:ptr_val]
return len(nums)