Problem 3785 · Medium

Minimum Swaps to Avoid Forbidden Values

Swap any two positions of nums until no index holds the value forbidden lists there; count the fewest swaps or report -1.

Open the interactive visualisation