描述
Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.
Example:
1 | Input: 3 |
分析
模拟题,注意边界情况即可。
解决方案1(Python)
1 | class Solution(object): |
解决方案2(Golang)
1 | func spiralOrder(matrix [][]int) []int { |
Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.
Example:
1 | Input: 3 |
模拟题,注意边界情况即可。
1 | class Solution(object): |
1 | func spiralOrder(matrix [][]int) []int { |