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
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 175. Combine Two Tables (0) | 2023.08.16 |
---|---|
[Leetcode] 2042. Check if Numbers Are Ascending in a Sentence (0) | 2023.08.14 |
[Leetcode] 383. Ransom Note (0) | 2023.08.11 |
[Leetcode] 511. Game Play Analysis I (0) | 2023.08.10 |
[Leetcode] 1342. Number of Steps to Reduce a Number to Zero (0) | 2023.08.09 |