-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2efc976
commit 23c9e5a
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<h2><a href="https://leetcode.com/problems/count-square-submatrices-with-all-ones/?envType=daily-question&envId=2024-10-27">1277. Count Square Submatrices with All Ones</a></h2><h3>Medium</h3><hr><p>Given a <code>m * n</code> matrix of ones and zeros, return how many <strong>square</strong> submatrices have all ones.</p> | ||
|
||
<p> </p> | ||
<p><strong class="example">Example 1:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> matrix = | ||
[ | ||
[0,1,1,1], | ||
[1,1,1,1], | ||
[0,1,1,1] | ||
] | ||
<strong>Output:</strong> 15 | ||
<strong>Explanation:</strong> | ||
There are <strong>10</strong> squares of side 1. | ||
There are <strong>4</strong> squares of side 2. | ||
There is <strong>1</strong> square of side 3. | ||
Total number of squares = 10 + 4 + 1 = <strong>15</strong>. | ||
</pre> | ||
|
||
<p><strong class="example">Example 2:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> matrix = | ||
[ | ||
[1,0,1], | ||
[1,1,0], | ||
[1,1,0] | ||
] | ||
<strong>Output:</strong> 7 | ||
<strong>Explanation:</strong> | ||
There are <b>6</b> squares of side 1. | ||
There is <strong>1</strong> square of side 2. | ||
Total number of squares = 6 + 1 = <b>7</b>. | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>1 <= arr.length <= 300</code></li> | ||
<li><code>1 <= arr[0].length <= 300</code></li> | ||
<li><code>0 <= arr[i][j] <= 1</code></li> | ||
</ul> |