day01_leetcode_Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.
For example,
Given n = 3
,
You should return the following matrix:
[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ] ]
使用python编写的话,针对二维数组的操作就需要变换下思路了。
本人思路:
1、创建对应的行数
2、使用针对x\y范围的限制
3、方向状态机