Skip to content

Commit 37d0b19

Browse files
committed
Fix minor text edits for Set Matrix Zeros
1 parent 477b529 commit 37d0b19

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

โ€Žset-matrix-zeroes/KwonNayeon.pyโ€Ž

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
- 1 <= m, n <= 200
66
- -2^31 <= matrix[i][j] <= 2^31 - 1
77
8-
Time Complexity: O(m*n)
9-
- m์€ ํ–‰, n์€ ์—ด์„ ์˜๋ฏธ
10-
- 0 ์ฐพ๊ธฐ: O(m*n)
11-
- ํ–‰๊ณผ ์—ด ๋ณ€ํ™˜: O(m*n)
8+
<Solution 1>
129
13-
Space Complexity: O(m*n)
14-
- zeros ๋ฐฐ์—ด์ด ์ตœ๋Œ€ m*n ํฌ๊ธฐ๊นŒ์ง€ ์ €์žฅ ๊ฐ€๋Šฅ
10+
Time Complexity: O(m * n)
11+
- m์€ ํ–‰, n์€ ์—ด์„ ์˜๋ฏธํ•จ
12+
- 0 ์ฐพ๊ธฐ: O(m * n)
13+
- ํ–‰๊ณผ ์—ด ๋ณ€ํ™˜: O(m * n)
14+
15+
Space Complexity: O(m * n)
16+
- zeros ๋ฐฐ์—ด์ด ์ตœ๋Œ€ m * n ํฌ๊ธฐ๊นŒ์ง€ ์ €์žฅ ๊ฐ€๋Šฅ
1517
1618
ํ’€์ด ๋ฐฉ๋ฒ•:
17-
1. 0 ์œ„์น˜ ์ €์žฅ
19+
1. 0 ์œ„์น˜๋ฅผ ํƒ์ƒ‰/์ €์žฅ
1820
2. ์ €์žฅ๋œ 0์˜ ํ–‰๊ณผ ์—ด์„ ๋ชจ๋‘ 0์œผ๋กœ ๋ณ€ํ™˜
19-
3. ์ฃผ์˜์ : ํ–‰๋ ฌ ๊ฐ’ ํƒ์ƒ‰๊ณผ ๋ณ€๊ฒฝ์„ ๋™์‹œ์— ์ˆ˜ํ–‰ํ•˜๋ฉด ์›๋ž˜ ์–ด๋–ค ๊ฐ’์ด 0์ด์—ˆ๋Š”์ง€ ๊ตฌ๋ถ„ํ•˜๊ธฐ ์–ด๋ ค์›Œ์ง
2021
"""
21-
2222
class Solution:
2323
def setZeroes(self, matrix: List[List[int]]) -> None:
2424
"""
@@ -32,17 +32,21 @@ def setZeroes(self, matrix: List[List[int]]) -> None:
3232
zeros.append((r, c))
3333

3434
for r, c in zeros:
35+
# ํ–‰(row)์„ 0์œผ๋กœ ์ฑ„์›€
3536
for i in range(len(matrix[0])):
3637
matrix[r][i] = 0
38+
# ์—ด(column)์„ 0์œผ๋กœ ์ฑ„์›€
3739
for i in range(len(matrix)):
3840
matrix[i][c] = 0
3941

4042
"""
41-
Time Complexity: O(m*n)
42-
- ํ–‰๋ ฌ ์ˆœํšŒ: O(m*n)
43-
- ํ–‰๊ณผ ์—ด ๋ณ€ํ™˜: O(m*n)
43+
<Solution 2>
44+
45+
Time Complexity: O(m * n)
46+
- ํ–‰๋ ฌ ์ˆœํšŒ: O(m * n)
47+
- ํ–‰๊ณผ ์—ด ๋ณ€ํ™˜: O(m * n)
4448
45-
Space Complexity: O(m+n)
49+
Space Complexity: O(m + n)
4650
- zero_rows: O(m)
4751
- zero_cols: O(n)
4852
@@ -51,7 +55,6 @@ def setZeroes(self, matrix: List[List[int]]) -> None:
5155
2. ํ–‰๊ณผ ์—ด ์ •๋ณด๋ฅผ ๋ถ„๋ฆฌ ์ €์žฅํ•˜์—ฌ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํšจ์œจ์ ์œผ๋กœ ์‚ฌ์šฉ
5256
3. ํ–‰๊ณผ ์—ด์„ ๋…๋ฆฝ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜์—ฌ ๋ถˆํ•„์š”ํ•œ ๋ฐ˜๋ณต ์—ฐ์‚ฐ ์ œ๊ฑฐ
5357
"""
54-
5558
class Solution:
5659
def setZeroes(self, matrix: List[List[int]]) -> None:
5760
"""
@@ -75,7 +78,9 @@ def setZeroes(self, matrix: List[List[int]]) -> None:
7578
matrix[i][c] = 0
7679

7780
"""
78-
Time Complexity: O(m*n)
81+
<Solution 3>
82+
83+
Time Complexity: O(m * n)
7984
8085
Space Complexity: O(1)
8186
- ์ถ”๊ฐ€์ ์ธ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ์ฒซ ํ–‰๊ณผ ์—ด์„ ๋งˆ์ปค๋กœ ํ™œ์šฉํ•˜์—ฌ ํ•ด๊ฒฐ

0 commit comments

Comments
ย (0)