- class Solution:
- def rotate(self, matrix: List[List[int]]) -> None:
- for i in range(len(matrix)):
- for l in range(i,len(matrix[0])):
- matrix[i][l],matrix[l][i]=matrix[l][i],matrix[i][l]
- for i in range(len(matrix)):
- l=0
- r=len(matrix[0])-1
- while l<r:
- matrix[i][l],matrix[i][r]=matrix[i][r],matrix[i][l]
- l+=1
- r-=1
转置后,每一行翻转