Spiral Matrix1 [Leetcode] 54. Spiral Matrix (Python) class Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: def check(matrix): for i in range(len(matrix)): for j in range(len(matrix[i])): if matrix[i][j] == 0: return True return False row = len(matrix) col = len(matrix[0]) visited = [[0]*col for i in range(row)] ans = [] # left: [0,1], down:[1,0], right: [0,-1], up: [-1,0] move = [0, 1] y = 0 x = 0 while check(visited): if co.. 2022. 1. 24. 이전 1 다음