Array
3551. Minimum Swaps to Sort by Digit Sum
The answer never looks at the numbers themselves. It looks at the shape of the permutation that carries the array to its target: n minus the number of cycles in that permutation, and nothing else.
Loading…