Duplicate Zeros
Description
Given a fixed length array arr
of integers, duplicate each occurrence of zero, shifting the remaining elements to the right.
Note that elements beyond the length of the original array are not written.
Do the above modifications to the input array in place, do not return anything from your function.
Example 1:
Example 2:
Note:
1 <= arr.length <= 10000
0 <= arr[i] <= 9
Solution
More concise solution
Last updated