We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8684a5e commit c25ac8aCopy full SHA for c25ac8a
1 file changed
rotate-image/ppxyn1.py
@@ -0,0 +1,32 @@
1
+# idea: -
2
+# Time Complexity: O(n^2)
3
+
4
+'''
5
+1 2 3
6
+4 5 6
7
+7 8 9
8
9
+class Solution:
10
+ def rotate(self, matrix: List[List[int]]) -> None:
11
+ """
12
+ Do not return anything, modify matrix in-place instead.
13
14
+ n = len(matrix)
15
+ # Transpose (diagonal elements are fixed)
16
+ '''
17
+ 1 4 7
18
+ 2 5 8
19
+ 3 6 9
20
21
+ for i in range(n):
22
+ for j in range(i+1,n):
23
+ matrix[i][j] , matrix[j][i] = matrix[j][i], matrix[i][j]
24
25
+ # Reverse each row
26
27
+ 7 4 1
28
+ 8 5 2
29
+ 9 6 3
30
31
+ for r in matrix:
32
+ r.reverse()
0 commit comments