mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
36 lines
1.1 KiB
HTML
36 lines
1.1 KiB
HTML
<p>给你一个 <code>m x n</code> 的矩阵,其中的值均为非负整数,代表二维高度图每个单元的高度,请计算图中形状最多能接多少体积的雨水。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode.com/uploads/2021/04/08/trap1-3d.jpg" /></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong> heightMap = [[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]]
|
||
<strong>输出:</strong> 4
|
||
<strong>解释:</strong> 下雨后,雨水将会被上图蓝色的方块中。总的接雨水量为1+2+1=4。
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode.com/uploads/2021/04/08/trap2-3d.jpg" /></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong> heightMap = [[3,3,3,3,3],[3,2,2,2,3],[3,2,1,2,3],[3,2,2,2,3],[3,3,3,3,3]]
|
||
<strong>输出:</strong> 10
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>m == heightMap.length</code></li>
|
||
<li><code>n == heightMap[i].length</code></li>
|
||
<li><code>1 <= m, n <= 200</code></li>
|
||
<li><code>0 <= heightMap[i][j] <= 2 * 10<sup>4</sup></code></li>
|
||
</ul>
|
||
|
||
<p> </p>
|