Always start by running through some examples to get a feel for the problem. With [1, 0, 2, 0, 4, 0]
, let's walk through the steps-- in this case, it may be best to work backwards.
We want to end up with [1, 2, 4, 0, 0, 0]
. To do that, it seems like we need to separate out [1, 2, 4]
and [0, 0, 0]
, so there's 3 things to consider.
