728x90
난이도 : easy
nums에서 0을 뒤로 전부 미는 문제
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
a = [x for x, val in enumerate(nums) if val == 0]
for i in range(len(a)-1, -1, -1):
del nums[a[i]]
nums.append(0)
Runtime : 11ms (25.72%)
Memory : 18.6.MB (60.92%)
728x90
'코딩 공부 > Leetcode' 카테고리의 다른 글
[Python] 1051. Height Checker (0) | 2025.01.31 |
---|---|
[Python] 905. Sort Array By Parity (0) | 2025.01.30 |
[Python] 1299. Replace Elements with Greatest Element on Right Side (0) | 2025.01.28 |
[Python] 1462. Course Schedule IV (0) | 2025.01.28 |
[Python] 941. Valid Mountain Array (0) | 2025.01.27 |