【leetcode❤python】27. Remove Element

#-*- coding: UTF-8 -*-
class Solution(object):
    def removeElement(self, nums, val):
        """
        :type nums: List[int]
        :type val: int
        :rtype: int
        """
        for i in range(len(nums)-1,-1,-1):
            if nums[i]==val:
                del nums[i]
        
        return len(nums)
    
sol=Solution()
print sol.removeElement([3,2,2,3], 3)

posted @ 2016-10-12 17:07  火金队长  阅读(144)  评论(0编辑  收藏  举报