algos_and_structures/leetcode/array_27_remove_element/best_solution.py
2024-11-02 14:03:30 +03:00

11 lines
275 B
Python

from typing import List
class Solution:
def removeElement(self, nums: List[int], val: int) -> int:
index = 0
for i in range(len(nums)):
if nums[i] != val:
nums[index] = nums[i]
index += 1
return index