diff --git a/python/remove_element.py b/python/remove_element.py new file mode 100644 index 0000000..f82c8cc --- /dev/null +++ b/python/remove_element.py @@ -0,0 +1,8 @@ +class Solution: + def removeElement(self, nums: List[int], val: int) -> int: + n = len(nums) + for i in range(n-1, -1, -1): + if nums[i] == val: + del nums[i] + n -= 1 + return n