Skip to content

Commit de69e8d

Browse files
Add files via upload
1 parent bd949d6 commit de69e8d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Rotate Image/Rotate_Image.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 先转置,再水平旋转
2+
# 32ms 100%
3+
class Solution:
4+
def rotate(self, matrix):
5+
"""
6+
:type matrix: List[List[int]]
7+
:rtype: void Do not return anything, modify matrix in-place instead.
8+
"""
9+
n = len(matrix)
10+
for i in range(n):
11+
for j in range(i + 1, n):
12+
matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
13+
for row in matrix:
14+
row.reverse()

0 commit comments

Comments
 (0)