Class Solution
-
- All Implemented Interfaces:
public final class Solution
59 - Spiral Matrix II.
Medium
Given a positive integer
n
, generate ann x n
matrix
filled with elements from1
to <code>n<sup>2</sup></code> in spiral order.Example 1:
Input: n = 3
Output: [1,2,3,8,9,4,7,6,5]
Example 2:
Input: n = 1
Output: [1]
Constraints:
1 <= n <= 20
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final Array<IntArray>
generateMatrix(Integer n)
-
-
Method Detail
-
generateMatrix
final Array<IntArray> generateMatrix(Integer n)
-
-
-
-