Print like a wave

Given a two dimensional array, print the array in a sine wave order. i.e. print the first column top to bottom, next column bottom to top and so on.

Note : Print the elements separated by space.

Input format :

Line 1 : No. of rows & No. of columns (separated by space)

Line 2 : Row 1 elements (separated by space)

Line 3 : Row 2 elements (separated by space)

Line 4 : and so on

Sample Input
3 4
1  2  3  4 
5  6  7  8 
9 10 11 12
Sample Output
1 5 9 10 6 2 3 7 11 12 8 4

Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem