mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
35 lines
1.5 KiB
HTML
35 lines
1.5 KiB
HTML
<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> </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> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>m == grid.length</code></li>
|
||
<li><code>n == grid[i].length</code></li>
|
||
<li><code>3 <= m, n <= 150</code></li>
|
||
<li><code>0 <= grid[i][j] <= 10<sup>6</sup></code></li>
|
||
</ul>
|