Skip to content

Commit dbaa78d

Browse files
author
wuduhren
committed
updates
1 parent f14be0f commit dbaa78d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

problems/python3/rotate-image.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def rotate(self, matrix: List[List[int]]) -> None:
3+
l, r = 0, len(matrix[0])-1
4+
5+
while l<r:
6+
top = l
7+
bottom = r
8+
for i in range(r-l):
9+
topLeft = matrix[top][l+i]
10+
matrix[top][l+i] = matrix[bottom-i][l]
11+
matrix[bottom-i][l] = matrix[bottom][r-i]
12+
matrix[bottom][r-i] = matrix[top+i][r]
13+
matrix[top+i][r] = topLeft
14+
l += 1
15+
r -= 1
16+
#the outer layer is finisthed, going into the inner layer

0 commit comments

Comments
 (0)