mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-12 02:41:42 +08:00
update
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<p>给你一个长度为 <code>n</code> 的整数数组 <code>order</code> 和一个整数数组 <code>friends</code>。</p>
|
||||
|
||||
<ul>
|
||||
<li><code>order</code> 包含从 1 到 <code>n</code> 的每个整数,且 <strong>恰好出现一次 </strong>,表示比赛中参赛者按照 <strong>完成顺序 </strong>的 ID。</li>
|
||||
<li><code>friends</code> 包含你朋友们的 ID,按照 <strong>严格递增 </strong>的顺序排列。<code>friends</code> 中的每个 ID 都保证出现在 <code>order</code> 数组中。</li>
|
||||
</ul>
|
||||
|
||||
<p>请返回一个数组,包含你朋友们的 ID,按照他们的 <strong>完成顺序 </strong>排列。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong class="example">示例 1:</strong></p>
|
||||
|
||||
<div class="example-block">
|
||||
<p><strong>输入:</strong><span class="example-io">order = [3,1,2,5,4], friends = [1,3,4]</span></p>
|
||||
|
||||
<p><strong>输出:</strong><span class="example-io">[3,1,4]</span></p>
|
||||
|
||||
<p><strong>解释:</strong></p>
|
||||
|
||||
<p>完成顺序是 <code>[<u><strong>3</strong></u>, <u><strong>1</strong></u>, 2, 5, <u><strong>4</strong></u>]</code>。因此,你朋友的完成顺序是 <code>[3, 1, 4]</code>。</p>
|
||||
</div>
|
||||
|
||||
<p><strong class="example">示例 2:</strong></p>
|
||||
|
||||
<div class="example-block">
|
||||
<p><strong>输入:</strong><span class="example-io">order = [1,4,5,3,2], friends = [2,5]</span></p>
|
||||
|
||||
<p><strong>输出:</strong><span class="example-io">[5,2]</span></p>
|
||||
|
||||
<p><strong>解释:</strong></p>
|
||||
|
||||
<p>完成顺序是 <code>[1, 4, <u><strong>5</strong></u>, 3, <u><strong>2</strong></u>]</code>。因此,你朋友的完成顺序是 <code>[5, 2]</code>。</p>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= n == order.length <= 100</code></li>
|
||||
<li><code>order</code> 包含从 1 到 <code>n</code> 的每个整数,且恰好出现一次</li>
|
||||
<li><code>1 <= friends.length <= min(8, n)</code></li>
|
||||
<li><code>1 <= friends[i] <= n</code></li>
|
||||
<li><code>friends</code> 是严格递增的</li>
|
||||
</ul>
|
Reference in New Issue
Block a user