We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c86d5dd commit 9e17838Copy full SHA for 9e17838
1 file changed
이용훈/10주차/260304.js
@@ -0,0 +1,31 @@
1
+/**
2
+ * @param {number[][]} mat
3
+ * @return {number}
4
+ */
5
+var numSpecial = function(mat) {
6
+ const m = mat.length;
7
+ const n = mat[0].length;
8
+
9
+ const row = Array(m).fill(0);
10
+ const col = Array(n).fill(0);
11
12
+ for (let i = 0; i < m; i++) {
13
+ for (let j = 0; j < n; j++) {
14
+ if (mat[i][j] === 1) {
15
+ row[i]++;
16
+ col[j]++;
17
+ }
18
19
20
21
+ let answer = 0;
22
23
+ if (row[i] !== 1) continue;
24
25
26
+ if (mat[i][j] === 1 && col[j] === 1) answer++;
27
28
29
30
+ return answer;
31
+};
0 commit comments