0059. Spiral Matrix II

https://leetcode.com/problems/spiral-matrix-ii

Description

Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order.

Example 1:

Example 2:

Constraints:

  • 1 <= n <= 20

ac

Last updated

Was this helpful?