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 b329f41 commit 52cdd25Copy full SHA for 52cdd25
java/1582-special-positions-in-a-binary-matrix.java
@@ -0,0 +1,27 @@
1
+class Solution {
2
+ public int numSpecial(int[][] mat) {
3
+ int r = mat.length;
4
+ int c = mat[0].length;
5
+ int[] rowOnes = new int[r];
6
+ int[] colOnes = new int[c];
7
+
8
+ for(int i = 0; i < r; i++){
9
+ for(int j = 0; j < c; j++){
10
+ if(mat[i][j] == 1){
11
+ rowOnes[i]++;
12
+ colOnes[j]++;
13
+ }
14
15
16
17
+ int res = 0;
18
19
20
+ if(mat[i][j] == 1 && rowOnes[i] == 1 && colOnes[j] == 1){
21
+ res++;
22
23
24
25
+ return res;
26
27
+}
0 commit comments