跟26题一个思路
Runtime: 60 ms, faster than 23.48% of Python3 online submissions for Remove Element.
class Solution:
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
i,j=0,0
while(j < len(nums)):
if nums[j] != val:
nums[i] = nums[j]
i += 1
j += 1
else:
j +=1
return i