leet code - 59. Spiral Matrix II (medium, matrix)
leet code - 59. Spiral Matrix II (medium, matrix)Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order. Example 1: Input: n = 3Output: [[1,2,3],[8,9,4],[7,6,5]]Example 2:Input: n = 1Output: [[1]] Constraints:1 n이라는 숫자가 주어지면 n*n 크기의 매트릭스를 생성해나선 순회를 하면서 해당 순서의 숫자로 update def generateMatrix(self, n: int) -> List[List[int]]: x, y, ..
2025. 4. 17.