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 f39de4c commit 202dbd7Copy full SHA for 202dbd7
rotate-image/dev-jonghoonpark.md
@@ -0,0 +1,25 @@
1
+- 문제: https://leetcode.com/problems/rotate-image/
2
+- 풀이: https://algorithm.jonghoonpark.com/2024/07/22/leetcode-48
3
+
4
+```java
5
+class Solution {
6
+ public void rotate(int[][] matrix) {
7
+ int l = matrix.length;
8
9
+ int limit = (int) Math.ceil((double) l / 2);
10
+ for (int i = 0; i < limit; i++) {
11
+ for (int j = i; j < l - 1 - i; j++) {
12
+ int temp = matrix[i][j];
13
+ matrix[i][j] = matrix[l - j - 1][i];
14
+ matrix[l - j - 1][i] = matrix[l - i - 1][l - j - 1];
15
+ matrix[l - i - 1][l - j - 1] = matrix[j][l - i - 1];
16
+ matrix[j][l - i - 1] = temp;
17
+ }
18
19
20
+}
21
+```
22
23
+### TC, SC
24
25
+시간 복잡도는 `O(n^2)` 공간 복잡도는 `O(1)` 이다.
0 commit comments