question of the day: https://leetcode.com/problems/spiral-matrix-ii/#/description
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.
For example, given n=3
, return the following matrix:
[
[1,2,3],
[8,9,4],
[7,6,5]
]
Brute force: create a matrix with placeholder values, copy over my
code from day 11, and modify that spiral
motion code to replace values with ascending values of 1..n<sup>2</sup>
.
That'd be O(n^2)
space and runtime.