leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/567/
풀이
0갯수 count, 그만큼 remove하고 맨뒤에 append
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
if len(nums) == 1:
pass
else:
count_zero = nums.count(0)
for _ in range(count_zero):
nums.remove(0)
nums.append(0)
반응형
'Algorithm > Online judge' 카테고리의 다른 글
[LeetCode] Array > Rotate Image (0) | 2021.05.07 |
---|---|
[LeetCode] Array > Two Sum (0) | 2021.05.07 |
[LeetCode] Array > Plus One (0) | 2021.05.07 |
[LeetCode] Array > Intersection of Two Arrays II (0) | 2021.05.06 |
[LeetCode] Array > Single Number (0) | 2021.05.06 |