Skip to content

Commit 0f2bd4b

Browse files
committed
feat(soobing): week15 > rotate-image
1 parent a000e26 commit 0f2bd4b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

โ€Žrotate-image/soobing.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* ๋ฌธ์ œ ์„ค๋ช…
3+
* - 2์ฐจ์› ๋ฐฐ์—ด์„ 90๋„ in-place๋กœ ํšŒ์ „ํ•˜๊ธฐ
4+
*
5+
* ์•„์ด๋””์–ด
6+
* 1) ๋Œ€๊ฐ์„  ์ด๋™ + ์ขŒ์šฐ ์ด๋™
7+
*
8+
*/
9+
/**
10+
Do not return anything, modify matrix in-place instead.
11+
*/
12+
function rotate(matrix: number[][]): void {
13+
const n = matrix.length;
14+
for (let i = 0; i < n; i++) {
15+
for (let j = i + 1; j < n; j++) {
16+
const temp = matrix[i][j];
17+
matrix[i][j] = matrix[j][i];
18+
matrix[j][i] = temp;
19+
}
20+
}
21+
22+
for (let i = 0; i < n; i++) {
23+
matrix[i].reverse();
24+
}
25+
}

0 commit comments

Comments
ย (0)