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 2e7229f commit d24538bCopy full SHA for d24538b
rotate-image/samthekorean.py
@@ -0,0 +1,16 @@
1
+# TC : O(n^2)
2
+# SC : O(1)
3
+class Solution:
4
+ def rotate(self, matrix: List[List[int]]) -> None:
5
+ top, bottom = 0, len(matrix) - 1
6
+
7
+ while top < bottom:
8
+ left, right = top, bottom
9
+ for i in range(bottom - top):
10
+ topLeft = matrix[top][left + i]
11
+ matrix[top][left + i] = matrix[bottom - i][left]
12
+ matrix[bottom - i][left] = matrix[bottom][right - i]
13
+ matrix[bottom][right - i] = matrix[top + i][right]
14
+ matrix[top + i][right] = topLeft
15
16
+ top, bottom = top + 1, bottom - 1
0 commit comments