Update 0054.螺旋矩阵.md

This commit is contained in:
赵亚杰
2023-10-12 11:11:25 +08:00
committed by GitHub
parent 7f1c040b28
commit 4a3e9c6bbe

View File

@ -260,7 +260,7 @@ class Solution(object):
:type matrix: List[List[int]] :type matrix: List[List[int]]
:rtype: List[int] :rtype: List[int]
""" """
if len(matrix)==0 or len(matrix[0])==0 : # 判定List是否为空 if len(matrix) == 0 or len(matrix[0]) == 0 : # 判定List是否为空
return [] return []
row, col = len(matrix), len(matrix[0]) # 行数,列数 row, col = len(matrix), len(matrix[0]) # 行数,列数
loop = min(row, col) // 2 # 循环轮数 loop = min(row, col) // 2 # 循环轮数
@ -268,7 +268,7 @@ class Solution(object):
i, j =0, 0 i, j =0, 0
count = 0 # 计数 count = 0 # 计数
offset = 1 # 每轮减少的格子数 offset = 1 # 每轮减少的格子数
result = [0]*(row*col) result = [0] * (row * col)
while loop>0 :# 左闭右开 while loop>0 :# 左闭右开
i, j = stx, sty i, j = stx, sty
while j < col - offset : # 从左到右 while j < col - offset : # 从左到右