658. Arrays-Spiral Print Clockwise
0
Medium
Given a 2-dimensional array, print its elements in a clockwise spiral form.
Input Format
Provide two integers, M and N, representing the number of rows and columns in the array, respectively. Then, provide M * N integers representing the elements of the 2-dimensional array.
Output Format
Print all M * N integers separated by commas, with 'END' written at the end (as shown in the example).
Example
Input
4 4
11 12 13 14
21 22 23 24
31 32 33 34
41 42 43 44
Output
11, 12, 13, 14, 24, 34, 44, 43, 42, 41, 31, 21, 22, 23, 33, 32, END
Constraints
The values of both M and N must be integers between 1 and 100, inclusive.
Loading...
View Submissions
Console