Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Reach Target Array

Minimum Operations to Reach Target Array gives two integer arrays and lets each operation fix every current occurrence of one chosen value. Find the fewest operations to make the arrays equal.

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

Minimum Operations to Reach Target Array gives two integer arrays and lets each operation fix every current occurrence of one chosen value. Find the fewest operations to make the arrays equal.

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