两个指针的运用:
https://leetcode-cn.com/problems/remove-element
class Solution:
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
i = 0
n = len(nums)
while i < n:
if nums[i] == val:
nums[i] = nums[n-1]
n -= 1
else:
i += 1
return n