n * n 二维矩阵
旋转90度
解
- 转置
- 倒序每行
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
n = len(matrix)
for i in range(n):
for j in range(i + 1, n):
temp = matrix[i][j]
matrix[i][j] = matrix[j][i]
matrix[j][i] = temp
for i in range(n):
matrix[i] = matrix[i][::-1]