1 class Solution:
2 def duplicateZeros(self, arr: List[int]) -> None:
3 """
4 Do not return anything, modify arr in-place instead.
5 """
6 n = len(arr)
7 if n > 0:
8 i = 0
9 while i < n - 1:
10 if arr[i] == 0:
11 for j in range(n-2,i,-1):
12 arr[j+1] = arr[j]
13 arr[i+1] = 0
14 i += 2
15 else:
16 i += 1
转载于:https://www.cnblogs.com/asenyang/p/11031123.html