题解 | 顺时针旋转矩阵
顺时针旋转矩阵
https://www.nowcoder.com/practice/2e95333fbdd4451395066957e24909cc
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param mat int整型二维数组
# @param n int整型
# @return int整型二维数组
#
class Solution:
def rotateMatrix(self , mat: List[List[int]], n: int) -> List[List[int]]:
# write code here
n=len(mat)
m=len(mat[0])
print(n,m)
res=[]
for j in range(m):
temp=[]
for i in range(n):
temp.append(mat[i][j])
print(mat[i][j])
temp=list(reversed(temp))
#print(temp)
res.append(temp)
return res
#刷题#
查看3道真题和解析