medium
arrays
matrix
Problem Description
Given an integer n, you need to implement a function generate_spiral_matrix(n: int) -> List[List[int]] that generates a matrix of size n x n containing elements in a spiral order starting from the top-left corner and moving clockwise.
Examples
Example 1
Input: n = "3"
Output: [[1,2,3],[8,9,4],[7,6,5]]
Example 2
Input: n = 4
Output: [[1,2,3,4],[12,13,14,5],[11,16,15,6],[10,9,8,7]]
Example 3
Input: n = 1
Output: [[1]]
Running will execute all 3 cases.