Minimum Operations to Maximize Last Elements in Arrays
Decide whether the last pair is swapped, then charge one swap for each earlier index that cannot keep its pair as it is.
Decide whether the last pair is swapped, then charge one swap for each earlier index that cannot keep its pair as it is.