MatrixSimulation
Return all elements of a matrix in spiral order: left to right along the top row, down the right column, right to left along the bottom row, then up the left column, and so on inward.
Input
Line 1: r and c. Next r lines: c integers each.
Output
Print the elements in spiral order on one line, separated by spaces.
Constraints
1 <= r, c <= 200 -10^9 <= each value <= 10^9
Example 1
Input
3 3 1 2 3 4 5 6 7 8 9
Output
1 2 3 6 9 8 7 4 5
Around the edge, then the centre: 1 2 3 6 9 8 7 4 5.