본문 바로가기

IT/코딩테스트

[Leetcode] 1089. Duplicate Zeros

728x90

https://leetcode.com/problems/duplicate-zeros/

class Solution:
    def duplicateZeros(self, arr: List[int]) -> None:

        in_arr = arr.copy()
        in_len = len(in_arr)

        arr.clear()
        for i in in_arr:
            if len(arr) == in_len:
                break
            arr.append(i)
            
            if len(arr) == in_len:
                break
            if i == 0:
                arr.append(0)
728x90