LeetCode--移除元素(python版)

class Solution(object):
   def removeElement(self, nums, val):
       """
       :type nums: List[int]
       :type val: int
       :rtype: int
       """
       i=0
       for j in range(len(nums)):
           if nums[j]!=val:
               nums[i]=nums[j]
               i=i+1
       return i

你可能感兴趣的:(LeetCode--移除元素(python版))