Difficulty: Easy
https://leetcode.com/problems/duplicate-zeros/
The code is shown below:
class Solution:
def duplicateZeros(self, arr: List[int]) -> None:
"""
Do not return anything, modify arr in-place instead.
"""
i = 0
while i < len(arr) - 1:
if arr[i] != 0:
i += 1
continue
for j in range(len(arr) - 1, i, -1):
arr[j] = arr[j-1]
arr[i+1] = 0
i += 2