given a 1D array.The task is to convert it in to a 2D array and values
should be filled spirally while filling from 1D array

the size of 1D array is multiple of a constant say n.
the number of rows and columns of 2D array will be given.

say number of rows =R
say number of columns  = C

k*n <= R*C. where k*n =number of elements in 1D array
if (R*C > number of elements in 1D array)
then rest of the values will be zeros.
e.g.

n=5; k=3
R= 6
C= 3

input 1D array=[1,0,0,0,1,0,0,0,0,0,1,1,1,1,0]

output 2D array

1 0 0 0 1 0
1 0 0 0 0 0
1 1 1 0 0 0

here as 5*3<6*3 so ..18 -15 = 3

i.e 3 remaining values are filled as zeros.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to