3785. Minimum Swaps to Avoid Forbidden Values
You are given two integer arrays,
numsandforbidden, each of lengthn.You may perform the following operation any number of times (including zero):
- Choose two distinct indices
iandj, and swapnums[i]withnums[j].Return the minimum number of swaps required such that, for every index
i, the value ofnums[i]is not equal toforbidden[i]. If no amount of swaps can ensure that every index avoids its forbidden value, return -1.