short Python, two pointer


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

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.