
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
How can we check which indices of <code>nums1</code> will be considered for swapping? How to minimize the number of such operations?
It can be seen that greedily swapping values of indices where <code>nums1[i] == nums2[i]</code> is the most optimal choice. How many values cannot be swapped this way?
Find which indices we will swap these remaining values with, and if there are enough such indices.