Class Solution
java.lang.Object
g0001_0100.s0059_spiral_matrix_ii.Solution
59 - Spiral Matrix II.<p>Medium</p>
<p>Given a positive integer <code>n</code>, generate an <code>n x n</code> <code>matrix</code> filled with elements from <code>1</code> to <code>n2</code> in spiral order.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/11/13/spiraln.jpg" alt="" /></p>
<p><strong>Input:</strong> n = 3</p>
<p><strong>Output:</strong> [[1,2,3],[8,9,4],[7,6,5]]</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> n = 1</p>
<p><strong>Output:</strong> <a href="1">1</a></p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= n <= 20</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
generateMatrix
public int[][] generateMatrix(int n)
-