1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-25 17:50:26 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/美丽塔 I [beautiful-towers-i].html

38 lines
1.4 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>给定一个包含&nbsp;<code>n</code>&nbsp;个整数的数组&nbsp;<code>heights</code>&nbsp;表示&nbsp;<code>n</code>&nbsp;座连续的塔中砖块的数量。你的任务是移除一些砖块来形成一个 <strong>山脉状</strong> 的塔排列。在这种布置中,塔高度先是非递减,有一个或多个连续塔达到最大峰值,然后非递增排列。</p>
<p>返回满足山脉状塔排列的方案中,<strong>高度和的最大值</strong>&nbsp;</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<b>输入:</b>maxHeights = [5,3,4,1,1]
<b>输出:</b>13
<b>解释:</b>我们移除一些砖块来形成 heights = [5,3,3,1,1],峰值位于下标 0。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<b>输入:</b>maxHeights = [6,5,3,9,2,7]
<b>输出:</b>22
<strong>解释:</strong>我们移除一些砖块来形成 heights = [3,3,3,9,2,2],峰值位于下标 3。</pre>
<p><strong class="example">示例 3</strong></p>
<pre>
<b>输入:</b>maxHeights = [3,2,5,5,2,3]
<b>输出:</b>18
<strong>解释:</strong>我们移除一些砖块来形成 heights = [2,2,5,5,2,2],峰值位于下标 2 或 3。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n == heights.length &lt;= 10<sup>3</sup></code></li>
<li><code>1 &lt;= heights[i] &lt;= 10<sup>9</sup></code></li>
</ul>