본문 바로가기

IT/코딩테스트

[Leetcode] 27. Remove Element

728x90

https://leetcode.com/problems/remove-element/

class Solution:
    def removeElement(self, nums: List[int], val: int) -> int:
    	nums_count = len(nums)
        val_count = nums.count(val)

        for i in range(val_count):
            nums.remove(val)
            nums.append(val+1)

        return nums_count - val_count
728x90