spiral matrix II

🏠
 1 from typing import List
 2 
 3 class Solution:
 4     def generateMatrix(self, n: int) -> List[List[int]]:
 5         s = n * n
 6         m = [[s]]
 7         if n == 1:
 8             return [[1]]
 9         while True:
10             m = [[*reversed(x)] for x in zip(*m)]
11             m.insert(0, [*range(s-len(m[0]), s)])
12             s -= len(m[0])
13             if s <= 1:
14                 break
15         return m