What does "bin" have to do with this? It doesn't look like a binning problem.
So, apparently, the result should contain alternating
zeros
and values from
data
, starting with a zero, and filling to the end with
zero
, right?
So, how would you do it if you had two stacks of paper, one with 4 sheets with the values of
data
and one with 6 (10-4) sheets with
zeros
, and were going to make a single pile of paper in the same sequence as you want for
result
?
That's what your code needs to do.
This is really pretty straightforward.
Hint: You don't need
actually to deal with the zeros. When you use
new double[10]
to assign to
result
, C# has guaranteed to have filled it with zeros.
So ... are there "edge cases" that you haven't specified (or thought about)?
For example:
What if
data.Length
is greater than half of
result.Length<br />
?