Skip to content

Commit 48cbc54

Browse files
committed
feat: Solve rotate-image problem
1 parent 0fbc611 commit 48cbc54

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

rotate-image/hu6r1s.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
def rotate(self, matrix: List[List[int]]) -> None:
3+
"""
4+
Do not return anything, modify matrix in-place instead.
5+
[0][0] [0][1] [0][2]
6+
[1][0] [1][1] [1][2]
7+
[2][0] [2][1] [2][2]
8+
9+
[2][0] [1][0] [0][0]
10+
[2][1] [1][1] [0][1]
11+
[2][2] [1][2] [0][2]
12+
"""
13+
n = len(matrix)
14+
15+
for i in range(n):
16+
for j in range(i, n):
17+
matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
18+
19+
for i in range(n):
20+
matrix[i].reverse()

0 commit comments

Comments
 (0)