File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fishercoder .solutions ;
2
+
3
+ /**
4
+ * 1277. Count Square Submatrices with All Ones
5
+ *
6
+ * Given a m * n matrix of ones and zeros, return how many square submatrices have all ones.
7
+ *
8
+ * Example 1:
9
+ * Input: matrix =
10
+ * [
11
+ * [0,1,1,1],
12
+ * [1,1,1,1],
13
+ * [0,1,1,1]
14
+ * ]
15
+ * Output: 15
16
+ * Explanation:
17
+ * There are 10 squares of side 1.
18
+ * There are 4 squares of side 2.
19
+ * There is 1 square of side 3.
20
+ * Total number of squares = 10 + 4 + 1 = 15.
21
+ *
22
+ * Example 2:
23
+ * Input: matrix =
24
+ * [
25
+ * [1,0,1],
26
+ * [1,1,0],
27
+ * [1,1,0]
28
+ * ]
29
+ * Output: 7
30
+ * Explanation:
31
+ * There are 6 squares of side 1.
32
+ * There is 1 square of side 2.
33
+ * Total number of squares = 6 + 1 = 7.
34
+ *
35
+ * Constraints:
36
+ * 1 <= arr.length <= 300
37
+ * 1 <= arr[0].length <= 300
38
+ * 0 <= arr[i][j] <= 1
39
+ * */
40
+ public class _1277 {
41
+ public static class Solution1 {
42
+ public int countSquares (int [][] matrix ) {
43
+ int count = 0 ;
44
+ return count ;
45
+ }
46
+ }
47
+ }
You can’t perform that action at this time.
0 commit comments