digits. Double every zero: insert another zero right after it and shift all later elements to the right. The length of the array stays the same, so anything pushed past the right end is dropped.
Return the resulting array.
Try to do it without an extra array.digits=[3, 0, 5, 0, 7, 8] → [3, 0, 0, 5, 0, 0]
Each zero is repeated and the row shifts right: [3, 0, 0, 5, 0, 0]. The 7 and the 8 are pushed off the end and lost.
digits=[4, 1, 0] → [4, 1, 0]
The zero is last, so its copy has no room: the array stays [4, 1, 0].
digits=[6, 2, 9] → [6, 2, 9]
No zeros, so nothing changes.
digits=[3, 0, 5, 0, 7, 8]
[3, 0, 0, 5, 0, 0]
Run checks the first 3 tests in your browser. Submit checks all 37 tests on the server, hidden ones included.