1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/找出最具竞争力的子序列 [find-the-most-competitive-subsequence].html
2022-03-29 12:43:11 +08:00

33 lines
1.4 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>给你一个整数数组 <code>nums</code> 和一个正整数 <code>k</code> ,返回长度为 <code>k</code> 且最具 <strong>竞争力</strong><em> </em><code>nums</code> 子序列。</p>
<p>数组的子序列是从数组中删除一些元素(可能不删除元素)得到的序列。</p>
<p>在子序列 <code>a</code> 和子序列 <code>b</code> 第一个不相同的位置上,如果 <code>a</code> 中的数字小于 <code>b</code> 中对应的数字,那么我们称子序列 <code>a</code> 比子序列 <code>b</code>(相同长度下)更具 <strong>竞争力</strong> 。 例如,<code>[1,3,4]</code><code>[1,3,5]</code> 更具竞争力,在第一个不相同的位置,也就是最后一个位置上, <code>4</code> 小于 <code>5</code></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [3,5,2,6], k = 2
<strong>输出:</strong>[2,6]
<strong>解释:</strong>在所有可能的子序列集合 {[3,5], [3,2], [3,6], [5,2], [5,6], [2,6]} 中,[2,6] 最具竞争力。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [2,4,3,3,5,4,9,6], k = 4
<strong>输出:</strong>[2,3,3,4]
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
<li><code>0 <= nums[i] <= 10<sup>9</sup></code></li>
<li><code>1 <= k <= nums.length</code></li>
</ul>