题解 | #顺时针打印矩阵#
顺时针打印矩阵
https://www.nowcoder.com/practice/9b4c81a02cd34f76be2659fa0d54342a
from re import L
# -*- coding:utf-8 -*-
class Solution:
# matrix类型为二维列表,需要返回列表
def printMatrix(self, matrix):
result = []
while matrix:
print(matrix)
result += matrix[0] # 添加矩阵的第一行
matrix = list(zip(*matrix[1:]))[::-1] # 去掉第一行并旋转矩阵
return result
查看25道真题和解析