3668. Restore Finishing Order Easy
1/**
2 * [3668] Restore Finishing Order
3 *
4 * You are given an integer array order of length n and an integer array friends.
5 *
6 * order contains every integer from 1 to n exactly once, representing the IDs of the participants of a race in their finishing order.
7 * friends contains the IDs of your friends in the race sorted in strictly increasing order. Each ID in friends is guaranteed to appear in the order array.
8 *
9 * Return an array containing your friends' IDs in their finishing order.
10 *
11 * <strong class="example">Example 1:
12 * <div class="example-block">
13 * Input: <span class="example-io">order = [3,1,2,5,4], friends = [1,3,4]</span>
14 * Output: <span class="example-io">[3,1,4]</span>
15 * Explanation:
16 * The finishing order is [<u>3</u>, <u>1</u>, 2, 5, <u>4</u>]. Therefore, the finishing order of your friends is [3, 1, 4].
17 * </div>
18 * <strong class="example">Example 2:
19 * <div class="example-block">
20 * Input: <span class="example-io">order = [1,4,5,3,2], friends = [2,5]</span>
21 * Output: <span class="example-io">[5,2]</span>
22 * Explanation:
23 * The finishing order is [1, 4, <u>5</u>, 3, <u>2</u>]. Therefore, the finishing order of your friends is [5, 2].
24 * </div>
25 *
26 * Constraints:
27 *
28 * 1 <= n == order.length <= 100
29 * order contains every integer from 1 to n exactly once
30 * 1 <= friends.length <= min(8, n)
31 * 1 <= friends[i] <= n
32 * friends is strictly increasing
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/restore-finishing-order/
38// discuss: https://leetcode.com/problems/restore-finishing-order/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn recover_order(order: Vec<i32>, friends: Vec<i32>) -> Vec<i32> {
44 vec![]
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_3668() {
56 }
57}
58Back
© 2026 bowen.ge All Rights Reserved.