1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/柱状图中最大的矩形 [0ynMMM].html

37 lines
1.2 KiB
HTML
Raw Normal View History

2022-03-27 20:38:29 +08:00
<p>给定非负整数数组 <code>heights</code>&nbsp;,数组中的数字用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 <code>1</code></p>
<p>求在该柱状图中,能够勾勒出来的矩形的最大面积。</p>
<p>&nbsp;</p>
<p><strong>示例 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/01/04/histogram.jpg" /></p>
<pre>
<strong>输入:</strong>heights = [2,1,5,6,2,3]
<strong>输出:</strong>10
<strong>解释:</strong>最大的矩形为图中红色区域,面积为 10
</pre>
<p><strong>示例 2</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/01/04/histogram-1.jpg" /></p>
<pre>
<strong>输入:</strong> heights = [2,4]
<b>输出:</b> 4</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= heights.length &lt;=10<sup>5</sup></code></li>
<li><code>0 &lt;= heights[i] &lt;= 10<sup>4</sup></code></li>
</ul>
<p>&nbsp;</p>
<p><meta charset="UTF-8" />注意:本题与主站 84&nbsp;题相同:&nbsp;<a href="https://leetcode-cn.com/problems/largest-rectangle-in-histogram/">https://leetcode-cn.com/problems/largest-rectangle-in-histogram/</a></p>