We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 117dc26 commit 5b55cc9Copy full SHA for 5b55cc9
허현빈/8주차/Set Matrix Zeroes.js
@@ -0,0 +1,30 @@
1
+/**
2
+ * @param {number[][]} matrix
3
+ * @return {void} Do not return anything, modify matrix in-place instead.
4
+ */
5
+var setZeroes = function (matrix) {
6
+ const dir = [
7
+ [1, 0],
8
+ [-1, 0],
9
+ [0, 1],
10
+ [0, -1],
11
+ ];
12
+
13
+ const q = [];
14
+ for (let i = 0; i < matrix.length; i++) {
15
+ for (let j = 0; j < matrix[0].length; j++) {
16
+ if (matrix[i][j] === 0) {
17
+ q.push([i, j]);
18
+ }
19
20
21
+ while (q.length) {
22
+ const [curY, curX] = q.shift();
23
24
+ matrix[i][curX] = 0;
25
26
+ for (let i = 0; i < matrix[0].length; i++) {
27
+ matrix[curY][i] = 0;
28
29
30
+};
0 commit comments