Add Remove Element

This commit is contained in:
Kiril Kovachev 2024-03-08 17:14:04 +00:00
parent 046a2c87e9
commit 707e68cf0a

8
python/remove_element.py Normal file
View File

@ -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