Sort Array by Moving Items to Empty Space
Split the moves into cycles of the target mapping: a cycle holding the empty slot costs its length minus one, any other costs its length plus one.
Split the moves into cycles of the target mapping: a cycle holding the empty slot costs its length minus one, any other costs its length plus one.