代码拉取完成,页面将自动刷新
<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>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。