← 返回 bytedance 的题目列表Spiral Matrix Fill
类型:online_judge
Given an integer n, create an n x n matrix filled with numbers from 1 to n^2 in spiral order starting from the top left corner in a clockwise manner.
Input and Output Example:
Input: n = 3 Output:
[
[ 1, 2, 3 ],
[ 8, 9, 4 ],
[ 7, 6, 5 ]
]
Data Scale:
1 <= n <= 20
Example
Input
2