All problems
1079EasyArrayTwo Pointers

Doubling the Blanks on a Fixed Strip

Tracked in this browser only
Write code

Trains the technique from

LeetCode 1089Duplicate Zeros

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

A strip of digits reads strip. Every 0 on it is a blank.

Double each blank in place: each 0 becomes two 0s and everything after it shifts one place along. The strip keeps its original length, so whatever is pushed off the end is lost.

Return the strip afterwards.

Examples

Example 1

Input
strip = [0, 1, 2]
Output
[0, 0, 1]

The single blank becomes two, pushing everything along, and the last entry falls off the end.

Example 2

Input
strip = [5, 6, 7]
Output
[5, 6, 7]

There is no blank anywhere, so nothing moves.

Example 3

Input
strip = [0, 0]
Output
[0, 0]

The first blank doubles into both places, and the second blank's copies both fall off the end.

Constraints

  • 1 <= strip.length <= 10^4
  • 0 <= strip[i] <= 9

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def duplicate_zeros(strip: list[int]) -> list[int]:
Java
public int[] duplicateZeros(int[] strip)
September 7
Apply