Skip to content

Commit fc342a0

Browse files
committed
Create README - LeetHub
1 parent 86fc689 commit fc342a0

File tree

1 file changed

+40
-0
lines changed
  • 1628-count-submatrices-with-all-ones

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<h2><a href="https://leetcode.com/problems/count-submatrices-with-all-ones">1628. Count Submatrices With All Ones</a></h2><h3>Medium</h3><hr><p>Given an <code>m x n</code> binary matrix <code>mat</code>, <em>return the number of <strong>submatrices</strong> that have all ones</em>.</p>
2+
3+
<p>&nbsp;</p>
4+
<p><strong class="example">Example 1:</strong></p>
5+
<img alt="" src="https://assets.leetcode.com/uploads/2021/10/27/ones1-grid.jpg" style="width: 244px; height: 245px;" />
6+
<pre>
7+
<strong>Input:</strong> mat = [[1,0,1],[1,1,0],[1,1,0]]
8+
<strong>Output:</strong> 13
9+
<strong>Explanation:</strong>
10+
There are 6 rectangles of side 1x1.
11+
There are 2 rectangles of side 1x2.
12+
There are 3 rectangles of side 2x1.
13+
There is 1 rectangle of side 2x2.
14+
There is 1 rectangle of side 3x1.
15+
Total number of rectangles = 6 + 2 + 3 + 1 + 1 = 13.
16+
</pre>
17+
18+
<p><strong class="example">Example 2:</strong></p>
19+
<img alt="" src="https://assets.leetcode.com/uploads/2021/10/27/ones2-grid.jpg" style="width: 324px; height: 245px;" />
20+
<pre>
21+
<strong>Input:</strong> mat = [[0,1,1,0],[0,1,1,1],[1,1,1,0]]
22+
<strong>Output:</strong> 24
23+
<strong>Explanation:</strong>
24+
There are 8 rectangles of side 1x1.
25+
There are 5 rectangles of side 1x2.
26+
There are 2 rectangles of side 1x3.
27+
There are 4 rectangles of side 2x1.
28+
There are 2 rectangles of side 2x2.
29+
There are 2 rectangles of side 3x1.
30+
There is 1 rectangle of side 3x2.
31+
Total number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24.
32+
</pre>
33+
34+
<p>&nbsp;</p>
35+
<p><strong>Constraints:</strong></p>
36+
37+
<ul>
38+
<li><code>1 &lt;= m, n &lt;= 150</code></li>
39+
<li><code>mat[i][j]</code> is either <code>0</code> or <code>1</code>.</li>
40+
</ul>

0 commit comments

Comments
 (0)