Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make a Subsequence

med
30 min
Try to solve the Minimum Operations to Make a Subsequence problem.

Statement

You are given an array target consisting of distinct integers and an integer array arr.

In a single operation, you can insert any integer at any position of arr. You may perform this operation any number of times.

Return the minimum number of operations required to make target a subsequence of arr.

Note: A subsequence of an array is a sequence derived by deleting zero or more elements from the array without altering the relative order of the remaining elements.

Constraints:

  • 1≤1 \leq target.length, arr.length ≤105\leq 10^5

  • 1≤1 \leq target[i], arr[i] ≤109\leq 10^9

  • target contains no duplicates.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make a Subsequence

med
30 min
Try to solve the Minimum Operations to Make a Subsequence problem.

Statement

You are given an array target consisting of distinct integers and an integer array arr.

In a single operation, you can insert any integer at any position of arr. You may perform this operation any number of times.

Return the minimum number of operations required to make target a subsequence of arr.

Note: A subsequence of an array is a sequence derived by deleting zero or more elements from the array without altering the relative order of the remaining elements.

Constraints:

  • 1≤1 \leq target.length, arr.length ≤105\leq 10^5

  • 1≤1 \leq target[i], arr[i] ≤109\leq 10^9

  • target contains no duplicates.