Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Reach Target Array

Try to solve the Minimum Operations to Reach Target Array problem.

Statement

You are given two integer arrays nums and target of length n.

In one operation, you can choose an integer x and set nums[i] = target[i] for all indices i where nums[i] == x.

Return the minimum number of operations required to make nums equal to target.

Constraints:

  • 1≤1 \leq n ==== nums.length ==== target.length ≤105\leq 10^5

  • 1≤1 \leq nums[i], target[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Reach Target Array

Try to solve the Minimum Operations to Reach Target Array problem.

Statement

You are given two integer arrays nums and target of length n.

In one operation, you can choose an integer x and set nums[i] = target[i] for all indices i where nums[i] == x.

Return the minimum number of operations required to make nums equal to target.

Constraints:

  • 1≤1 \leq n ==== nums.length ==== target.length ≤105\leq 10^5

  • 1≤1 \leq nums[i], target[i] ≤105\leq 10^5