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 fe5e3ab commit 3dc182aCopy full SHA for 3dc182a
rotate-image/hyer0705.ts
@@ -0,0 +1,20 @@
1
+/**
2
+ Do not return anything, modify matrix in-place instead.
3
+ */
4
+// Time Complexity: O(n^2), n: matrix의 한 변의 길이
5
+// Space Complexity: O(1)
6
+function rotate(matrix: number[][]): void {
7
+ const n = matrix.length;
8
+
9
+ for (let i = 0; i < n; i++) {
10
+ for (let j = i + 1; j < n; j++) {
11
+ [matrix[i][j], matrix[j][i]] = [matrix[j][i], matrix[i][j]];
12
+ }
13
14
15
16
+ for (let j = 0; j < Math.floor(n / 2); j++) {
17
+ [matrix[i][j], matrix[i][n - j - 1]] = [matrix[i][n - j - 1], matrix[i][j]];
18
19
20
+}
0 commit comments