Approach
This is really easy problem. For those nums that are the same as target, we don’t need to change it.
For the rest, we only need to check how many unique numbers occur in nums, and that is the answer.
Code
class Solution {
public:
int minOperations(vector<int>& nums, vector<int>& target) {
unordered_set<int> pat;
int n = nums.size();
for(int i = 0 ; i < n ; ++i) {
if(nums[i] == target[i]) continue;
pat.insert(nums[i]);
}
return pat.size();
}
};