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 1f174be commit 9250b9eCopy full SHA for 9250b9e
โrotate-image/yyyyyyyyyKim.pyโ
@@ -0,0 +1,25 @@
1
+"""
2
+LeetCode 48. Rotate Image
3
+https://leetcode.com/problems/rotate-image/
4
+
5
+summary:
6
+n x n ํ๋ ฌ์ ์๊ณ ๋ฐฉํฅ์ผ๋ก 90๋ ํ์ (in-place, ์ถ๊ฐ ๊ณต๊ฐ์์ด ํ๋ ฌ ์์ฒด๋ฅผ ์์ )
7
8
+class Solution:
9
+ def rotate(self, matrix: List[List[int]]) -> None:
10
+ """
11
+ Do not return anything, modify matrix in-place instead.
12
13
+ # ์๊ฐ๋ณต์ก๋ O(n^2), ๊ณต๊ฐ๋ณต์ก๋ O(1)
14
15
+ n = len(matrix)
16
17
+ # ํ๊ณผ ์ด ๋ฐ๊พธ๊ธฐ
18
+ for i in range(n):
19
+ for j in range(i+1, n):
20
+ matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
21
22
+ # ํ์ ์ข์ฐ๋ฐ์ ํ๊ธฐ
23
24
+ for j in range(n//2):
25
+ matrix[i][j], matrix[i][n-j-1] = matrix[i][n-j-1], matrix[i][j]
0 commit comments