Tap here to switch tabs
Problem
Submissions

Problem: Restore Finishing Order

med
30 min
Try to solve the Restore Finishing Order problem.

Statement

You are given an integer array order of length nn, representing the finishing order of nn participants labeled from 11 to nn. You are also given an integer array friends containing the labels of a subset of these participants.

Return an array representing the finishing order of your friends, preserving their relative positions as they appear in order.

Constraints:

  • 1≤n==1 \leq n == order.length ≤100\leq 100

  • order contains every integer from 11 to nn exactly once

  • 1≤1 \leq friends.length ≤min⁡(8,n)\leq \min(8, n)

  • 1≤1 \leq friends[i] ≤n\leq n

  • friends is strictly increasing

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Restore Finishing Order

med
30 min
Try to solve the Restore Finishing Order problem.

Statement

You are given an integer array order of length nn, representing the finishing order of nn participants labeled from 11 to nn. You are also given an integer array friends containing the labels of a subset of these participants.

Return an array representing the finishing order of your friends, preserving their relative positions as they appear in order.

Constraints:

  • 1≤n==1 \leq n == order.length ≤100\leq 100

  • order contains every integer from 11 to nn exactly once

  • 1≤1 \leq friends.length ≤min⁡(8,n)\leq \min(8, n)

  • 1≤1 \leq friends[i] ≤n\leq n

  • friends is strictly increasing