0054. 螺旋矩阵 #55
utterances-bot
started this conversation in
Comments
Replies: 3 comments
-
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
res = []
while matrix:
res += matrix.pop(0)
if not matrix:
break
matrix = self.turnMatrix(matrix)
return res
def turnMatrix(self, matrix: List[List[int]]) -> List[int]:
rows = len(matrix)
cols = len(matrix[0])
newmat = []
for i in range(cols):
newrow = []
for j in range(rows):
newrow.append(matrix[j][i])
newmat.append(newrow)
newmat.reverse()
return newmat |
Beta Was this translation helpful? Give feedback.
0 replies
-
class Solution:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
你好!思路里面的第二点中的叙述应为“按照顺时针的顺序”,你写成逆时针了。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
0054. 螺旋矩阵 | 算法通关手册
https://algo.itcharge.cn/Solutions/0001-0099/spiral-matrix/
Beta Was this translation helpful? Give feedback.
All reactions