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)/最大化数组的伟大值 [maximize-greatness-of-an-array].html
2023-03-24 20:17:23 +08:00

32 lines
1.2 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>给你一个下标从 0 开始的整数数组&nbsp;<code>nums</code>&nbsp;。你需要将&nbsp;<code>nums</code>&nbsp;重新排列成一个新的数组&nbsp;<code>perm</code>&nbsp;</p>
<p>定义 <code>nums</code>&nbsp;<strong>伟大值</strong>&nbsp;为满足&nbsp;<code>0 &lt;= i &lt; nums.length</code>&nbsp;&nbsp;<code>perm[i] &gt; nums[i]</code>&nbsp;的下标数目。</p>
<p>请你返回重新排列 <code>nums</code>&nbsp;后的 <strong>最大</strong>&nbsp;伟大值。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><b>输入:</b>nums = [1,3,5,2,1,3,1]
<b>输出:</b>4
<b>解释:</b>一个最优安排方案为 perm = [2,5,1,3,3,1,1] 。
在下标为 0, 1, 3 和 4 处,都有 perm[i] &gt; nums[i] 。因此我们返回 4 。</pre>
<p><strong>示例 2</strong></p>
<pre><b>输入:</b>nums = [1,2,3,4]
<b>输出:</b>3
<b>解释:</b>最优排列为 [2,3,4,1] 。
在下标为 0, 1 和 2 处,都有 perm[i] &gt; nums[i] 。因此我们返回 3 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>