very easy to understand with 39ms

'''

class Solution(object):

def removeElement(self, nums, val):

"""

:type nums: List[int]

:type val: int

:rtype: int

"""

k = 0

l = len(nums)

if val not in nums:

return l

for i in range(l):

if nums[i] == val:

k += 1

else:

nums[i-k] = nums[i]

return l-k

'''