Problem Description
Given an integer A, generate a square matrix filled with elements from 1 to A2 in spiral order and return the generated square matrix.
1 <= A <= 1000
Return a 2-D matrix which consists of the elements added in spiral order.
Input 1:
1
Input 2:
2
Input 3:
5
Output 1:
[ [1] ]
Output 2:
[ [1, 2], [4, 3] ]
Output 2:
[ [1, 2, 3, 4, 5], [16, 17, 18, 19, 6], [15, 24, 25, 20, 7], [14, 23, 22, 21, 8], [13, 12, 11, 10, 9] ]
Explanation 1:
Only 1 is to be arranged.
Explanation 2:
1 --> 2 | | 4<--- 3
Explanation 3:
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.