leetcode——1089.复写零

 

class Solution(object):
    def duplicateZeros(self, arr):
        """
        :type arr: List[int]
        :rtype: None Do not return anything, modify arr in-place instead.
        """
        l=len(arr)
        i=0
        while i<l:
            if arr[i]!=0:
                i+=1
            else:
                arr.insert(i+1,0)
                arr.pop()
                i+=2
执行用时 :64 ms, 在所有 python 提交中击败了89.33%的用户
内存消耗 :11.9 MB, 在所有 python 提交中击败了100.00%的用户
 
——2019.10.28

 

posted @ 2019-10-28 21:27  欣姐姐  阅读(102)  评论(0编辑  收藏  举报