How do I locate all ones in a binary array and change all adjacent elements to ones?
For example, if I have [0 0 0 1 0 0 0 1 0 0],
how do I turn that into [0 0 1 1 1 0 1 1 1 0] ?
Thanks
[Edit] Ideally, I would like to be able to transform N # of elements on either side of every 1 to 1. For example, if N =3, then [0 0 0 0 0 1 0 0 0 0 0 0], would become [0 0 1 1 1 1 1 1 1 0 0 0].
Best Answer