2717. Semi-Ordered Permutation
You are given a 0-indexed permutation of
nintegersnums.A permutation is called semi-ordered if the first number equals
1and the last number equalsn. You can perform the below operation as many times as you want until you makenumsa semi-ordered permutation:
- Pick two adjacent elements in
nums, then swap them.Return the minimum number of operations to make
numsa semi-ordered permutation.A permutation is a sequence of integers from
1tonof lengthncontaining each number exactly once.
1 | class Solution { |