Skip to content

Commit 202dbd7

Browse files
week13 mission rotate-image
1 parent f39de4c commit 202dbd7

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

rotate-image/dev-jonghoonpark.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)