https://leetcode.com/problems/remove-element/#/description
class Solution(object):
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
lastpos = len(nums)-1
while lastpos>=0 and nums[lastpos]==val: lastpos-=1
i=0
while i<lastpos:
if nums[i]==val:
nums[i]=nums[lastpos]
lastpos-=1
while lastpos>=0 and nums[lastpos]==val: lastpos-=1
i+=1
return lastpos+1