Problem 2934 · Medium

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.

Open the interactive visualisation