Search
⌘K

Leetcode 2717. Semi-Ordered Permutation

Given a permutation, find the minimum number of adjacent swaps to make it "semi-ordered" (1 at index 0 and n at index n-1) — equivalently, move 1 left to the front and n right to the end, summing their distances but subtracting one if 1 is originally to the right of n because their moves overlap.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.