The original challenge description can be found here
Given a 2D matrix of size M*N. Traverse and print the matrix in spiral form.
- Array of values
- Dimension M (number of rows)
- Dimension N (number of columns)
Elements when travelled in Spiral form, will be displayed in a single line.
1 <=T<= 100
2 <= M, N <= 10
0 <= Ai <= 100
Input:
Array: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
M: 4
N: 4
Output:
[1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10]