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

33 lines
887 B
HTML
Raw Normal View History

2022-03-27 20:56:26 +08:00
<p>给定 <em>n</em> 个非负整数,用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 1 。</p>
<p>求在该柱状图中,能够勾勒出来的矩形的最大面积。</p>
<p> </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> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= heights.length <=10<sup>5</sup></code></li>
<li><code>0 <= heights[i] <= 10<sup>4</sup></code></li>
</ul>