1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/沙漏的最大总和 [maximum-sum-of-an-hourglass].html
2022-10-07 21:03:28 +08:00

35 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个大小为 <code>m x n</code> 的整数矩阵 <code>grid</code></p>
<p>按以下形式将矩阵的一部分定义为一个 <strong>沙漏</strong> </p>
<img alt="" src="https://assets.leetcode.com/uploads/2022/08/21/img.jpg" style="width: 243px; height: 243px;">
<p>返回沙漏中元素的 <strong>最大</strong> 总和。</p>
<p><strong>注意:</strong>沙漏无法旋转且必须整个包含在矩阵中。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2022/08/21/1.jpg" style="width: 323px; height: 323px;">
<pre><strong>输入:</strong>grid = [[6,2,1,3],[4,2,1,5],[9,2,8,7],[4,1,2,9]]
<strong>输出:</strong>30
<strong>解释:</strong>上图中的单元格表示元素总和最大的沙漏6 + 2 + 1 + 2 + 9 + 2 + 8 = 30 。
</pre>
<p><strong>示例 2</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2022/08/21/2.jpg" style="width: 243px; height: 243px;">
<pre><strong>输入:</strong>grid = [[1,2,3],[4,5,6],[7,8,9]]
<strong>输出:</strong>35
<strong>解释:</strong>上图中的单元格表示元素总和最大的沙漏1 + 2 + 3 + 5 + 7 + 8 + 9 = 35 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>m == grid.length</code></li>
<li><code>n == grid[i].length</code></li>
<li><code>3 &lt;= m, n &lt;= 150</code></li>
<li><code>0 &lt;= grid[i][j] &lt;= 10<sup>6</sup></code></li>
</ul>