title: How to add value to an array that matches the previous value
body: <p>I have a pretty simple problem that I'm trying to solve but can't seem to wrap my head around how to do it. If I had an array that consisted of <code>[1,3,2,7]</code> and after running the method would return <code>[1,1,3,3,2,2,7,7]</code> what would be the best way to do that? I also have a size variable that can increase the size of the array to make room, for example, after doing <strong><code>size*2</code></strong> I would get <code>[1,3,2,7,0,0,0,0]</code></p>
  <p>Any guidance would be appreciated :)</p>